Search Postgresql Archives

prepared SELECT and placeholders with NULL values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm having an issue using NULL values to fill placeholders in a
prepared SELECT statement. My table looks something like this:

CREATE TABLE person (id serial primary key, lname text not null, fname text);

Given queries like this (using the Perl DBI+DBD::Pg interface):
  $i = $db->prepare('INSERT INTO person (lname, fname) VALUES (?, ?)');
  $s = $db->prepare('SELECT id FROM person WHERE lname = ? AND fname = ?');

These insert operations work fine:
  $i->execute('Bono', 'Sonny');
  $i->execute('Cher', undef);

This select works properly as well, returning the appropriate "id" value:
  $s->execute('Bono', 'Sonny');

But this does not, returning an empty list:
  $s->execute('Cher', undef);

My environment:
  - PostgreSQL 8.1.3
  - Perl 5.8.8
  - DBI 1.50
  - DBD::Pg 1.43

Any ideas? Thanks.

- Mike


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux