Re: plpgsql functions and NULLs

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: plpgsql functions and NULLs
Дата
Msg-id 20050131132701.G12960@megazone.bigpanda.com
обсуждение исходный текст
Ответ на plpgsql functions and NULLs  (Don Drake <dondrake@gmail.com>)
Ответы Re: plpgsql functions and NULLs  (Don Drake <dondrake@gmail.com>)
Список pgsql-sql
On Sun, 30 Jan 2005, Don Drake wrote:

> OK, I have a function that finds records that changed in a set of
> tables and attempts to insert them into a data warehouse.
>
> There's a large outer loop of candidate rows and I inspect them to see
> if the values really changed before inserting.
>
> My problem is that when I look to see if the row exists in the
> warehouse already, based on some IDs, it fails when an ID is NULL.
> The ID is nullable, so that's not a problem.
>
> But I'm forced to write an IF statement looking for the potential NULL
> and write 2 queries:
>
> IF omcr_id is null
>    select * from ....
>    WHERE omcr_id is NULL
>    AND ...
> ELSE
>    select * from ....
>    WHERE omcr_id=candidate.omcr_id
>    AND ....
> END IF;

Hmm, perhaps some form like:

WHERE not(candidate.omcr_id is distinct from omcr_id)



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

Предыдущее
От: Thomas F.O'Connell
Дата:
Сообщение: Re: plpgsql functions and NULLs
Следующее
От: "Luiz Rafael Culik Guimaraes"
Дата:
Сообщение: number os commands inside transaction block