Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VMGPl-0001cy-23 for pgsql-admin@arkaria.postgresql.org; Wed, 18 Sep 2013 11:59:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VMGPk-00026W-86 for pgsql-admin@arkaria.postgresql.org; Wed, 18 Sep 2013 11:59:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VMGPj-00025r-2w for pgsql-admin@postgresql.org; Wed, 18 Sep 2013 11:59:23 +0000 Received: from mail.trovaprezzi.it ([2.228.21.217]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VMGQt-00087S-I5 for pgsql-admin@postgresql.org; Wed, 18 Sep 2013 12:00:38 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.trovaprezzi.it (Postfix) with ESMTP id B082382023; Wed, 18 Sep 2013 13:53:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.7pixel.local Received: from mail.trovaprezzi.it ([127.0.0.1]) by localhost (zimbra.7pixel.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LDy3-y2aa6K4; Wed, 18 Sep 2013 13:53:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.trovaprezzi.it (Postfix) with ESMTP id 39B82820A8; Wed, 18 Sep 2013 13:53:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.7pixel.local Received: from mail.trovaprezzi.it ([127.0.0.1]) by localhost (zimbra.7pixel.local [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4h54ijAXQiUd; Wed, 18 Sep 2013 13:53:37 +0200 (CEST) Received: from zimbra.7pixel.local (zimbra.7pixel.local [192.168.0.127]) by mail.trovaprezzi.it (Postfix) with ESMTP id 68C4D82023; Wed, 18 Sep 2013 13:53:37 +0200 (CEST) Date: Wed, 18 Sep 2013 13:53:37 +0200 (CEST) From: Roberto Grandi To: Albe Laurenz Cc: pgsql-admin@postgresql.org Message-ID: <515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it> In-Reply-To: References: <1725603904.387654.1379499282544.JavaMail.root@trovaprezzi.it> <452256586.387717.1379499437400.JavaMail.root@trovaprezzi.it> Subject: Re: Catch exceptions outside function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [91.204.80.113] X-Mailer: Zimbra 8.0.2_GA_5569 (ZimbraWebClient - FF23 (Win)/8.0.2_GA_5569) Thread-Topic: Catch exceptions outside function Thread-Index: glZu2ImBDkpEo87LW1ODUNYiVViPYfCK5IjAaUmQHb8= X-Pg-Spam-Score: 0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Hi this is my script in details, remember that I launch it by .Net code (devar= t connector): SET LOCAL statement_timeout TO 1000; BEGIN; SELECT pg_sleep(5); -- QUERY that is long running; -- Some exception catch such as EXCEPTION END; I supposed my code can throw an eception for timeout and I would catch it. = Otherwise consecutives queries report "Transaction is aborted message error= ". Do you have any suggestion for me? Thanks again Roberto ----- Messaggio originale ----- Da: "Albe Laurenz" A: "Roberto Grandi *EXTERN*" , pgsql-admin@p= ostgresql.org Inviato: Mercoled=C3=AC, 18 settembre 2013 12:41:01 Oggetto: RE: Catch exceptions outside function Roberto Grandi wrote: > I ask for your help cause I can't point out the solution to my problem on= PG 8.3 > I would catch an exception outside any function/procedure but directly wi= thin script. >=20 >=20 > BEGIN; >=20 > -- raise an exception code >=20 > EXCEPTION > WHEN 'exception_type' > THEN ROLLBACK; >=20 > COMMIT; >=20 > is it possible with PG 8.3? That's a bit unclear. What do you mean by "outside a function but in a script"? Can you explain in more detail? The code sample you paste looks like PL/pgSQL. You cannot commit or roll back in PL/pgSQL. If you want to undo in case of error whatever happens in the block, just replace the ROLLBACK with NOOP. Yours, Laurenz Albe --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin