Re: Oracle error log table equivalent in postgresql

Поиск
Список
Период
Сортировка
От 066ce286@free.fr
Тема Re: Oracle error log table equivalent in postgresql
Дата
Msg-id 59272590.782882796.1628254257380.JavaMail.root@zimbra82-e14.priv.proxad.net
обсуждение исходный текст
Ответ на Re: Oracle error log table equivalent in postgresql  (Mukesh Rajpurohit <vivasvan1902@gmail.com>)
Ответы Re: Oracle error log table equivalent in postgresql
Список pgsql-admin
> Thanks, but it solve just part of the problem. In oracle insert
> statement executes and rejected rows are inserted in error log table
> in same transaction. But, its similar feature or workaround seems
> hard in postgresql.

It's not hard.

You may either intercept the exception( EXCEPTION WHEN OTHER ...) so that the transaction will not be rollbacked, so
youcan easily insert into another table what you want.
 


But, if you want to rollback the transaction with a RAISE EXCEPTION, you just have to insert in your log table using
anothertransaction, for example with a loopback dblink.
 

Something like :

select setting INTO l_port FROM pg_settings WHERE name = 'port';
PERFORM * FROM dblink(
        FORMAT('dbname=%s user=%s port=%s',current_database(), current_user, l_port),
        FORMAT('INSERT INTO TRACE_ERROR(ernno,errmsg,errcontext) VALUES (%L,%L,%L);',l_errno,l_errmsg,l_errctx)
        ) AS p (ret text); 

Otherwise, when you rollback, the INSERT into the error log table will be also rollbacked.



В списке pgsql-admin по дате отправления:

Предыдущее
От: Vijaykumar Jain
Дата:
Сообщение: Re: Oracle error log table equivalent in postgresql
Следующее
От: Mukesh Rajpurohit
Дата:
Сообщение: Re: Oracle error log table equivalent in postgresql