Re: Catch exceptions outside function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux