prepared SELECT and placeholders with NULL values

Поиск
Список
Период
Сортировка
От Michael Lea
Тема prepared SELECT and placeholders with NULL values
Дата
Msg-id 9c393a720603231324o58d77da7q27254573c6d92702@mail.gmail.com
обсуждение исходный текст
Ответы Re: prepared SELECT and placeholders with NULL values  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Bjørn T Johansen
Дата:
Сообщение: Re: Logging of sql statements?
Следующее
От: "Brian Kitzberger"
Дата:
Сообщение: Re: version problem with pg_dump