replace null with 0 in subselect ?

From: "Albrecht Berger" <berger1517(at)gmx(dot)ch>
To: "pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: replace null with 0 in subselect ?
Date: 2002-10-16 10:07:59
Message-ID: 05f001c274fb$e8a5aba0$a07ba8c0@wxp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,
I have a statement like this :

INSERT INTO tab1 (c1, c2, c3) VALUES (1,2, SELECT MAX(pos)+1 FROM tab2);

This works fine if the subselect returns a value, but if it returns
null there is a problem. In this case a 0 has to be inserted.
Is there any pg function which solves this problem ?
I know that oracle has a function but I didn't find
something similar in pg.

Thanks
berger

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ludwig Lim 2002-10-16 11:40:43 Locking that will delayed a SELECT
Previous Message John Geng 2002-10-16 09:31:18