Re: How to insert in a table the error returns by query

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to insert in a table the error returns by query
Date: 2015-01-28 16:55:00
Message-ID: 1422464100577-5835803.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-sql by date

  From Date Subject
Next Message ciamblex 2015-01-28 17:49:52 Re: How to insert in a table the error returns by query
Previous Message Andy Colson 2015-01-26 20:05:07 Re: check if the same function is already running, then exit!