Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C048F475C14 for ; Mon, 9 Dec 2002 19:47:25 -0500 (EST) Received: from smtp.netsite.com.br (servmail1.netsite.com.br [200.187.175.84]) by postgresql.org (Postfix) with ESMTP id 16028475BEC for ; Mon, 9 Dec 2002 19:47:25 -0500 (EST) Received: from server2000 (netsite-fac-f2-250.idial.com.br [200.225.232.250]) by smtp.netsite.com.br (Postfix) with SMTP id 5D97D290887 for ; Mon, 9 Dec 2002 22:47:18 -0200 (BRST) Message-ID: <001201c29fef$05abcae0$0101a8c0@Info2000.com.br> From: =?iso-8859-1?Q?2000_Inform=E1tica?= <2000info@netsite.com.br> To: "PG SQL Mailim" References: <20021209143049.71054.qmail@web20102.mail.yahoo.com> Subject: Re: ISNULL FUNCTION Date: Mon, 9 Dec 2002 22:53:56 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/109 X-Sequence-Number: 10697 ----- Original Message ----- From: "Héctor Iturre" To: Sent: Monday, December 09, 2002 11:30 AM Subject: [SQL] ISNULL FUNCTION > HI, > HERE IS AN ALTERNATIVE TO USE THE SQL SERVER > ISNULL() FUNCTION > > > select case when FIELD_NAME isnull then 'EXPRESION' > else FIELD_NAME end > from calfiscal > where impuesto = 1 > > Ahora podés usar Yahoo! Messenger desde tu celular. Aprendé cómo hacerlo en Yahoo! Móvil: http://ar.mobile.yahoo.com/sms.html > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html Segue um exemplo que funciona satisfatoriamente. Recrie esta função alterando os parametros (text, text e RETURNS text) para os tipos que lhe for necessario. CREATE FUNCTION isnull(text, text) RETURNS text AS 'SELECT (CASE (SELECT $1 is null) WHEN true THEN $2 ELSE $1 END) AS RESULT' LANGUAGE 'sql'; COMMENT ON FUNCTION isnull(text, text) IS 'Retorna o 2º arg se o 1º for nulo';