Re: Extending COALESCE()

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Extending COALESCE()
Дата
Msg-id AANLkTinBOWypD=XMvjmeKHYfc4yZ=Z+vc-pm=kWrCM0C@mail.gmail.com
обсуждение исходный текст
Ответ на Extending COALESCE()  (David Frankson <David.Frankson@infinitecampus.com>)
Список pgsql-general
Hello

I am afraid, so this isn't possible. You have to use a explicit cast
"int to bool"

select coalesce(true, 0::bool)

regards

Pavel Stehule

2010/11/23 David Frankson <David.Frankson@infinitecampus.com>:
> Is it possible to extend the COALESCE() function?  I would like to support
> for coalescing an int into a Boolean, but I get syntax errors if I don’t
> wrap coalesce in quotes.
>
>
>
> CREATE OR REPLACE FUNCTION coalesce(boolean,int) RETURNS boolean AS $$
>
>
>
>                 SELECT CASE WHEN $1 IS NOT NULL THEN $1 WHEN $2 = 1 THEN
> true ELSE false END
>
>
>
> $$ LANGUAGE sql IMMUTABLE;
>
>
>
>
>
> Thanks,
>
>
>
> Dave

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

Предыдущее
От: Jayadevan M
Дата:
Сообщение: Re: Debug advice when postgres connection maxing out
Следующее
От: Armand Turpel
Дата:
Сообщение: json data type