Re: How to insert in a table the error returns by query - Mailing list pgsql-sql

From David G Johnston
Subject Re: How to insert in a table the error returns by query
Date
Msg-id 1422464100577-5835803.post@n5.nabble.com
Whole thread Raw
List pgsql-sql
ciamblex wrote
> I need to save in a table the error code (SQLSTATE) and the error message
> (SQLERRM) returned by an insert or an update. My procedure must execute an
> insert, and if an error occurs, it must be saved into an apposite table. 
> 
> But the problem is that if I use the EXCEPTION BLOCK, when an error occurs
> the transaction is aborted and any command after cannot be execute. 
> 
> How can I save the error returned by a query in a table, using PLPGSQL??? 
> 
> Thanks

The typical solution seems to be to use dblink to open an independent
session that is not affected by rollback when the main session cronks.  I'm
not sure if FDWs work for this purpose...

David J.



--
View this message in context:
http://postgresql.nabble.com/How-to-insert-in-a-table-the-error-returns-by-query-tp5835771p5835803.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: check if the same function is already running, then exit!
Next
From: ciamblex
Date:
Subject: Re: How to insert in a table the error returns by query