Thread: Choppin' Blanks with DBI and DBD::Pg

Choppin' Blanks with DBI and DBD::Pg

From
Wade Burgett
Date:
A bit of a newbie perl hacker here but I am having some problems getting
the whitespace removed from the end of my records.  I am not sure
whether this is due to my stuffing the hash incorrectly or some
misunderstanding of DBD-DBI and the ChopBlanks attribute, or the cosmic
random factor.

When I return records from my database (using the slect statement below)
I get the full field length of characters, which includes whitespace,
which I don't want.  It looked like what I wanted was the ChopBlanks
attribute from DBD:Pg

here's the man:   ChopBlanks (boolean,inherited)       Supported by the driver as proposed by DBI. This          method
issimilar to the SQL-function RTRIM. sounds like it takes off trailing whitespace (but I could be wrong
 
here).

Here's my perl:

#initialize options
%MyAtts = ('ChopBlanks',True);

#Connection to database (OBject)
$dbh = DBI->connect("DBI:Pg:dbname=$database");

if ( !defined $dbh ) {                                  die "Cannot do \$dbh->connect:
$DBI::errstr\n";    };
#Prepare then execute query
$sth = $dbh->prepare("Select firstname, lastname, username, passwd,
username, winpasswd from $table where unixdone ='N'",\%MyAtts );
$sth->execute;

Things I tried:

using 1 instead of true in ChopBlanks
not using the \ in front of %ChopBLanks after the select statement
(generates error).
initializing the hash w/ => syntax (no change)

Thanks for any help.  Aplogies if this is some sillly syntax error (but
my -w isn't complaining so ? )


Wade