Re: referential integrity violation

Поиск
Список
Период
Сортировка
От Mike Beachy
Тема Re: referential integrity violation
Дата
Msg-id 20021021140712.GA17251@marketdude.com
обсуждение исходный текст
Ответ на Re: referential integrity violation  (mk@fashaf.co.za)
Список 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 по дате отправления:

Предыдущее
От: Medi Montaseri
Дата:
Сообщение: need help with a table shrinker
Следующее
От: "John"
Дата:
Сообщение: Re: Error on import