Re: When is a record NULL?

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: When is a record NULL?
Дата
Msg-id 2CA937FC-2501-442E-BB3E-879D12132370@kineticode.com
обсуждение исходный текст
Ответ на Re: When is a record NULL?  ("David E. Wheeler" <david@kineticode.com>)
Ответы Re: When is a record NULL?  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: When is a record NULL?  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
On Jul 24, 2009, at 2:59 PM, David E. Wheeler wrote:

>    FETCH have INTO rec_have;
>    FETCH want INTO rec_want;
>    WHILE NOT rec_have IS NULL OR NOT rec_want IS NULL LOOP
>        IF rec_have IS DISTINCT FROM rec_want THEN
>            RETURN false;
>        END IF;
>        rownum = rownum + 1;
>        FETCH have INTO rec_have;
>        FETCH want INTO rec_want;
>    END LOOP;
>    RETURN true;

Bah. It fails to do what I want when I pass cursors that return:
        VALUES (NULL, NULL), (NULL, NULL)        VALUES (NULL, NULL)

So when it gets to that second row in the first cursor, it doesn't  
know it's a row with NULLs as opposed to an empty row. So this bit:
   WHILE NOT rec_have IS NULL OR NOT rec_want IS NULL LOOP

Obviously isn't detecting the difference. I tried
    WHILE (NOT rec_have IS NULL AND rec_have IS DISTINCT FROM NULL)       OR (NOT rec_want IS NULL AND rec_want IS
DISTINCTFROM NULL)
 

and
    WHILE (NOT rec_have IS NULL AND NOT rec_have IS NOT DISTINCT FROM  
NULL)       OR (NOT rec_want IS NULL AND NOT rec_want IS NOT DISTINCT FROM  
NULL)

But they didn't work, either.

There's got to be a way to do this; better, there ought to be an easy  
way to tell the difference. :-(

Thanks,

David


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: SE-PostgreSQL Specifications
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Non-blocking communication between a frontend and a backend (pqcomm)