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.