Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66A854765B3 for ; Wed, 16 Oct 2002 06:07:55 -0400 (EDT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 3E4F9475C5F for ; Wed, 16 Oct 2002 06:07:53 -0400 (EDT) Received: (qmail 8756 invoked by uid 0); 16 Oct 2002 10:07:54 -0000 Received: from pd9e0dfa6.dip.t-dialin.net (HELO wxp) (217.224.223.166) by mail.gmx.net (mp019-rz3) with SMTP; 16 Oct 2002 10:07:54 -0000 Message-ID: <05f001c274fb$e8a5aba0$a07ba8c0@wxp> From: "Albrecht Berger" To: "pgsql" Subject: replace null with 0 in subselect ? Date: Wed, 16 Oct 2002 12:07:59 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/171 X-Sequence-Number: 9888 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