Re: Catch exceptions outside function

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: Catch exceptions outside function
Дата
Msg-id A737B7A37273E048B164557ADEF4A58B17C22011@ntex2010a.host.magwien.gv.at
обсуждение исходный текст
Ответ на Re: Catch exceptions outside function  (Roberto Grandi <roberto.grandi@trovaprezzi.it>)
Список pgsql-admin
Roberto Grandi wrote:
> 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?

I see.

You cannot catch an exception in SQL, as far as I know (unless you use a DO
statement, which was introduced in PostgreSQL 9.0).

You could use a "poor man's DO" by creating a function that does
what you want, catch the exception in PL/pgSQL, call the function and drop it.

But I really think that this should be handled on the application side,
i.e. your code should ignore the exception.

Yours,
Laurenz Albe

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

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