Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id A10FE475AD1 for ; Sat, 1 Jun 2002 00:06:21 -0400 (EDT) Received: from MAIN.compiere.org (static023-26-151-24.nt02-c3.cpe.charter-ne.com [24.151.26.23]) by postgresql.org (Postfix) with ESMTP id 833B1475977 for ; Sat, 1 Jun 2002 00:04:26 -0400 (EDT) Subject: Any way to handle exceptions in PL/pgSQL ? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sat, 1 Jun 2002 00:11:44 -0400 Content-Transfer-Encoding: quoted-printable Message-ID: <6E2C6F49B3E09548A38EDCAD31C4182F04DDA0@MAIN.compiere.org> content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4712.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Any way to handle exceptions in PL/pgSQL ? Thread-Index: AcIJInC0QjDPAakFTeeyDEQ5dphaOQ== From: "Jorg Janke" To: X-Archive-Number: 200206/1 X-Sequence-Number: 7966 Is there any way to handle failed queries in PL/pgSQL? << I am aware that the example can be re-worded in a single query; This is a question more on how to do the 'procedural' part >> Example: 1st query if OK, return result 2ne query if OK, return result return error message Is it correct, that if a function fails, it returns null ?? -- Function: message_get(varchar) CREATE FUNCTION message_get(varchar) RETURNS varchar AS ' DECLARE p_key ALIAS FOR $1; v_RetValue Message.MsgText%TYPE; BEGIN SELECT MsgText INTO v_RetValue=20 FROM User_Message=20 WHERE Value =3D p_Value; -- if ok ?? RETURN v_RetValue; SELECT Text INTO v_RetValue=20 FROM Sys_Message WHERE Value =3D p_Value; -- if ok ?? RETURN v_RetValue; RETURN 'nothing found'; END; ' LANGUAGE 'plpgsql'; Cheers, Jorg Janke (203) 445-9503 http://www.compiere.org Smart ERP & CRM Business Solution for Distribution and Service globally ------------------------------------------------------------------------ General questions/issues: http://sourceforge.net/forum/?group_id=3D29057 Support via: http://sourceforge.net/tracker/?group_id=3D29057&atid=3D410216 ------------------------------------------------------------------------