From: | "Michael Lea" <michael(dot)lea(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | prepared SELECT and placeholders with NULL values |
Date: | 2006-03-23 21:24:16 |
Message-ID: | 9c393a720603231324o58d77da7q27254573c6d92702@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Kitzberger | 2006-03-23 21:32:52 | Re: version problem with pg_dump |
Previous Message | Bjørn T Johansen | 2006-03-23 21:19:06 | Re: Logging of sql statements? |