Quote function is not supposed to quote ? character.

You must do as follows:
>         my $dbh = DBI->connect("DBI:Pg:dbname=test", "postgres", "");
>         my $val = q!\'?:!
>         my $sth = $dbh->prepare("INSERT INTO foo (a) values (?)");
>         $sth->execute($val);

(And no explicit calls to quote are necessary)

On Wed, 29 Aug 2001, Alex Krohn wrote:

> Hi,
> 
> I came across this problem that seems to be with DBD::Pg's quote
> function that is easily reproducible. This test script:
> 
>         my $dbh = DBI->connect("DBI:Pg:dbname=test", "postgres", "");
>         my $val = $dbh->quote(q!\'?:!);
>         print "val: $val\n";
>         my $sth = $dbh->prepare("INSERT INTO foo (a) values ($val)");
>         $sth->execute;
> 
> produces:
> 
>         DBD::Pg::st execute failed: parameter unknown at mytest.pl line 6.
> 
> If I use mysql, or Oracle, as a driver, it works as expected. I searched
> through the list, and the only answer seemed to be to use placeholders,
> which isn't really an option in my situation.
> 
> Any ideas on workarounds, or a patch to DBD::Pg would be great. 
> 
> Please cc me any replies as I'm not on the list.
> 
> Cheers,
> 
> Alex
> 
> 

Reply via email to