From: | Mike Beachy <beachy(at)marketboy(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: referential integrity violation |
Date: | 2002-10-21 14:07:12 |
Message-ID: | 20021021140712.GA17251@marketdude.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Oct 21, 2002 at 10:27:29AM +0200, mk(at)fashaf(dot)co(dot)za wrote:
> I have tried '' , undef , 'NULL' , 'null' non of them seem to work?
>
> any idea how to submit a NULL value with perl?
from the DBI man page:
Null Values
Undefined values, or "undef", can be used to indicate null
values. However, care must be taken in the particular
case of trying to use null values to qualify a "SELECT"
statement. Consider:
SELECT description FROM products WHERE product_code = ?
Binding an "undef" (NULL) to the placeholder will not
select rows which have a NULL "product_code"! Refer to the
SQL manual for your database engine or any SQL book for
the reasons for this. To explicitly select NULLs you have
to say ""WHERE product_code IS NULL"" and to make that
general you have to say:
... WHERE (product_code = ? OR (? IS NULL AND product_code IS NULL))
and bind the same value to both placeholders.
So, the answer is to bind undef. If it's not, please go into more detail of how you are using this...
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Doug McNaught | 2002-10-21 14:15:09 | Re: Migrating from Informix to Postgre |
Previous Message | Tom Lane | 2002-10-21 14:03:13 | Re: [PORTS] Problem compiling on HP/Compaq Tru64 UNIX |