Re: Catch exceptions outside function

Поиск
Список
Период
Сортировка
От Roberto Grandi
Тема Re: Catch exceptions outside function
Дата
Msg-id 515129598.391580.1379505217287.JavaMail.root@trovaprezzi.it
обсуждение исходный текст
Ответ на Re: Catch exceptions outside function  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Ответы Re: Catch exceptions outside function  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Re: Catch exceptions outside function  (David Johnston <polobo@yahoo.com>)
Re: Catch exceptions outside function  (Scott Ribe <scott_ribe@elevated-dev.com>)
Список pgsql-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
"Transactionis 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


В списке pgsql-admin по дате отправления:

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: Re: Catch exceptions outside function
Следующее
От: Albe Laurenz
Дата:
Сообщение: Re: Catch exceptions outside function