Choppin' Blanks with DBI and DBD::Pg

From: Wade Burgett <wadeb(at)ap(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org, wadeb(at)burgettsys(dot)com
Subject: Choppin' Blanks with DBI and DBD::Pg
Date: 1999-06-10 22:39:40
Message-ID: 37603EAC.C50BDC87@ap.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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 is similar 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

Browse pgsql-interfaces by date

  From Date Subject
Next Message Abd-Allah Abdul Karim 1999-06-11 02:16:17 php3
Previous Message Roland_DUBOULOZ 1999-06-10 15:03:34 subscribe