Re: referential integrity violation - Mailing list pgsql-general

From Mike Beachy
Subject Re: referential integrity violation
Date
Msg-id 20021021140712.GA17251@marketdude.com
Whole thread Raw
In response to Re: referential integrity violation  (mk@fashaf.co.za)
List pgsql-general
On Mon, Oct 21, 2002 at 10:27:29AM +0200, mk@fashaf.co.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

pgsql-general by date:

Previous
From: Medi Montaseri
Date:
Subject: need help with a table shrinker
Next
From: "John"
Date:
Subject: Re: Error on import