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