Quoting

[email protected] (Ralesk)
Newsgroups perl.dbd.pg
Message-ID <[email protected]>
Hi all,

I've been using the $dbh->quote method quite happily lately, but it raises 
some warnings which I find a bit odd.  If I read the documentation correctly, 
the type which we quote is one of the :pg_types, or the :sql_types (or 
whatever) from DBI.

The latter work fine, the Pg ones however will tell me this:

Unknown type 1043, defaulting to UNKNOWN at wherever.pl
Unknown type 17, defaulting to UNKNOWN at wherever.pl

Thankfully in most cases all we need is a few apostrophes around the value, 
and it doesn't actually cause problems, but I'd love to get rid of these.

Here's some code snippet (maybe I'm doing it wrong):

 $ean = DBH->quote($ean, PG_VARCHAR);
 $artist = defined $artist ? DBH->quote($artist, PG_VARCHAR) : 'NULL';
 $title = DBH->quote($title, PG_VARCHAR);

(Also, it would be cool if the quote function returned an apostrophe-less NULL 
if it encounters an undef value :)  Or is there a reason why it doesn't do 
that?)

Thanks,

-- 
R, who hasn't seen any kind of instruction on how to sign up to the mailing 
list...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.