IFNULL -> COALESCE

From: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
Subject: IFNULL -> COALESCE
Date: 2002-02-08 16:37:03
Message-ID: 15459.65199.280887.269425@kelvin.csl.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Guys, I've recently being going back over code from Ingres and porting
it over to PostgreSQL. Heavy use was made of the IFNULL function, this
function simply returns the 2nd argument if the first is
NULL. Consider the following query:

SELECT COALESCE(MAX(id), 0) + 1 from test;

can be replaced by the following PostgreSQL query:

SELECT COALESCE(MAX(id), 0) + 1 from test;

I've manually done this, but wouldn't this be a useful auto-tranlation
to make in the parser? Aid to porting and all...

Yeah, I know i should be using a SERIAL column, that's later work...

Regards, Lee.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2002-02-08 16:42:36 Re: PostgreSQL 7.2 on SlashDot
Previous Message Justin Clift 2002-02-08 16:34:32 Re: 7.2 - changed array_out() - quotes vs no quotes