Re: IFNULL -> COALESCE

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: IFNULL -> COALESCE
Дата
Msg-id 24776.1013192583@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: IFNULL -> COALESCE  (Lee Kindness <lkindness@csl.co.uk>)
Ответы Re: IFNULL -> COALESCE  (Lee Kindness <lkindness@csl.co.uk>)
Список pgsql-hackers
Lee Kindness <lkindness@csl.co.uk> writes:
> Okay, lets try that again...
>   SELECT IFNULL(MAX(id), 0) + 1 from test;
> can be replaced by the following PostgreSQL query:
>   SELECT COALESCE(MAX(id), 0) + 1 from test;

For any specific datatype that you might need this for, you could
provide a user-defined IFNULL function to avoid having to translate
your code.  Might get a bit tedious if you are doing it for a lot
of different datatypes, however.

Not sure if it's worth adding a keyword and a grammar production
to get Postgres to do this for you.  If it were part of a full-court
press to improve our Oracle compatibility, I wouldn't object, but
I'm not sure I see the point of doing just the one nonstandard
feature.
        regards, tom lane


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: IFNULL -> COALESCE
Следующее
От: Holger Krug
Дата:
Сообщение: Re: GiST on 64-bit box