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

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: How to insert in a table the error returns by query
Дата
Msg-id 1422464100577-5835803.post@n5.nabble.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: check if the same function is already running, then exit!
Следующее
От: ciamblex
Дата:
Сообщение: Re: How to insert in a table the error returns by query