pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Grandi <roberto.grandi@trovaprezzi.it>
To: Albe Laurenz <laurenz.albe@wien.gv.at>
Cc: pgsql-admin@postgresql.org
Subject: Re: Catch exceptions outside function
Date: Wed, 18 Sep 2013 13:53:37 +0200 (CEST)
Message-ID: <515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it> (raw)
In-Reply-To: <A737B7A37273E048B164557ADEF4A58B17C21F41@ntex2010a.host.magwien.gv.at>
References: <1725603904.387654.1379499282544.JavaMail.root@trovaprezzi.it>
	<452256586.387717.1379499437400.JavaMail.root@trovaprezzi.it>
	<A737B7A37273E048B164557ADEF4A58B17C21F41@ntex2010a.host.magwien.gv.at>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

Hi

this is my script in details, remember that I launch it by .Net code (devart 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" <laurenz.albe@wien.gv.at>
A: "Roberto Grandi *EXTERN*" <roberto.grandi@trovaprezzi.it>, pgsql-admin@postgresql.org
Inviato: Mercoledì, 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 within script.
> 
> 
> BEGIN;
> 
> -- raise an exception code
> 
> EXCEPTION
> WHEN 'exception_type'
> THEN ROLLBACK;
> 
> COMMIT;
> 
> 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


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



view thread (10+ messages)  latest in thread

Message-ID: <515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it>
Permalink:  ../515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it/
Also on:    postgresql.org/message-id/515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: roberto.grandi@trovaprezzi.it, laurenz.albe@wien.gv.at
  Subject: Re: Catch exceptions outside function
  In-Reply-To: <515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox