Re: Using null or not null in function arguments

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: Using null or not null in function arguments
Дата
Msg-id 20090123144539.GJ3008@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответ на Using null or not null in function arguments  (Igor Katson <descentspb@gmail.com>)
Ответы Re: Using null or not null in function arguments
Список pgsql-general
On Fri, Jan 23, 2009 at 02:16:34PM +0300, Igor Katson wrote:
> a) If the input argument is NULL, then the corresponding select
> statement will change from
>
> column = arg
> to
> column IS NULL

I think you want to use the IS [NOT] DISTINCT FROM operator.  It
works like the = and <> operators. i.e. the following expressions are
equivalent:

  x IS NOT DISTINCT FROM y

and

  CASE WHEN x IS NULL THEN y IS NULL
       ELSE COALESCE(x = y, FALSE) END


> b) If the input argument is NULL, then the corresponding select
> statement will be removed, so if it was not written.

not sure what you mean here, but maybe one of the existing suggestions
may help or the "RETURNS NULL ON NULL INPUT" flag when you're creating
the function may be what you're looking for.


--
  Sam  http://samason.me.uk/

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

Предыдущее
От: Howard Cole
Дата:
Сообщение: Re: How to convert ByteA to Large Objects
Следующее
От: Sam Mason
Дата:
Сообщение: Re: How to convert ByteA to Large Objects