That's definitely a bug.  For now, try to escape it with \?, or if that
doesn't work, then try using a placeholder ? and then bind 'val?' to it.

Ilya

-----Original Message-----
From: Anton Pitts
To: [EMAIL PROTECTED]
Sent: 12/1/02 11:16 PM
Subject: How to insert a question mark?

I'm running postgresql 7.3, perl 5.6.0, DBI 1.30 on mac os x 10.2 and 
am having trouble with inserting values ending in a question mark.

I first tried interpolating the value into a query string:
   $dbh->do("INSERT INTO ref (citekey, title) VALUES ('why?', 'bob')");
This doesn't raise an error, but the values get inserted into the
database as
    citekey | title
   ---------+-------
    whyNULL | bob

Using $dbh->quote did not resolve the problem.  My best guess was 
that the ? is interpreted as a placeholder which isn't being bound to 
anything, and I could not figure out how to escape it from the DBI, 
so I tried using placeholders as:

   my $sth = $dbh-> prepare('INSERT INTO ref (citekey, title) VALUES
(?,?)');
   $sth->execute('bob', 'what?');
   $sth->execute('why?', 'john');

The first execute works fine; the second fails with

   DBD::PgPP::st execute failed: ERROR:  parser: parse error at or 
near "john" at character 47

What might I be missing here?

Thanks,

Anton.

Reply via email to