Re: IFNULL -> COALESCE - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: IFNULL -> COALESCE
Date
Msg-id 20020208102617.Y44162-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: IFNULL -> COALESCE  (Lee Kindness <lkindness@csl.co.uk>)
List pgsql-hackers
On Fri, 8 Feb 2002, Lee Kindness wrote:

> Christopher Kings-Lynne writes:
>  > lkindness@csl.co.uk writes:
>  > >  SELECT COALESCE(MAX(id), 0) + 1 from test;
>  > > can be replaced by the following PostgreSQL query:
>  > >  SELECT COALESCE(MAX(id), 0) + 1 from test;
>  > Ummm...did you make a mistake here?  Those statements are
>  > identical...
>
> 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;

Might be nice to have it done automatically, but as a workaround
why not just define ifnull(int, int) - or whatever types are
necessary.

create function ifnull(int, int) returns int as
'select coalesce($1, $2);' language 'sql';
should work for 7.1 and above unless I'm missing something.





pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Maintaining the list of release changes
Next
From: Tom Lane
Date:
Subject: Re: IFNULL -> COALESCE