Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BDE986330DC for ; Wed, 21 Oct 2009 13:25:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54114-03 for ; Wed, 21 Oct 2009 16:25:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by mail.postgresql.org (Postfix) with ESMTP id C9E9C632F76 for ; Wed, 21 Oct 2009 13:25:48 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1N0e0S-0003pv-Al for pgsql-sql@postgresql.org; Wed, 21 Oct 2009 09:25:48 -0700 Message-ID: <25995788.post@talk.nabble.com> Date: Wed, 21 Oct 2009 09:25:48 -0700 (PDT) From: maboyz To: pgsql-sql@postgresql.org Subject: @@Error equivalent in Postgresql MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: thabani.moyo@distributel.ca X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/88 X-Sequence-Number: 33287 Hi, I am in the process of migrating our database from MS Server 2000 to Postgres. I have a bunch of stored procs which i have to modify the syntax so they work in postgresql. My ? is is there an equivalent for the @@Error function in T-SQL for postgres: The stored proc i am converting is: ALTER PROCEDURE [dbo].[AuditAccounts] @ReturnValue int output AS SET NOCOUNT ON select * from AdminAccts full join AmAccts on adm_acc_AccountNo = am_acc_AccountNo where adm_acc_AccountNo is null or am_acc_AccountNo is null Set @ReturnValue = @@Error I have wriiten the postgres function as follows : CREATE TYPE AuditAccount AS (adm_acc_AccountNo character varying, am_acc_AccountNo character varying); CREATE FUNCTION dint_AuditAccounts( ) RETURNS SETOF AuditAccount AS $BODY$ BEGIN RETURN QUERY select * from "AdminAccounts" full join "AmAccounts" on "adm_acc_AccountNo" = "am_acc_AccountNo" where "adm_acc_AccountNo" is null or "am_acc_AccountNo" is null; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100 ROWS 10; How do i implement exception handling in this case, if i want the function to report back successful execution or failure just like the @@Error function does in T-SQL? -- View this message in context: http://www.nabble.com/%40%40Error-equivalent-in-Postgresql-tp25995788p25995788.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com.