From: Wade Burgett <wadeb@ap.com>
To: pgsql-interfaces@postgresql.org
To: wadeb@burgettsys.com
Subject: Choppin' Blanks with DBI and DBD::Pg
Date: Thu, 10 Jun 1999 15:39:40 -0700
Message-ID: <37603EAC.C50BDC87@ap.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: wadeb@ap.com, wadeb@burgettsys.com
Subject: Re: Choppin' Blanks with DBI and DBD::Pg
In-Reply-To: <37603EAC.C50BDC87@ap.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox