Search Postgresql Archives

Re: Extending COALESCE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>:
> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux