From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Lee Kindness <lkindness(at)csl(dot)co(dot)uk> |
Cc: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: IFNULL -> COALESCE |
Date: | 2002-02-08 18:29:00 |
Message-ID: | 20020208102617.Y44162-100000@megazone23.bigpanda.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 8 Feb 2002, Lee Kindness wrote:
> Christopher Kings-Lynne writes:
> > lkindness(at)csl(dot)co(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-02-08 18:29:26 | Re: Maintaining the list of release changes |
Previous Message | Tom Lane | 2002-02-08 18:23:03 | Re: IFNULL -> COALESCE |