how to force an insert before Raise Exception?

Поиск
Список
Период
Сортировка
От giova
Тема how to force an insert before Raise Exception?
Дата
Msg-id 1303220363098-4313283.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: how to force an insert before Raise Exception?  (Adrian Klaver <adrian.klaver@gmail.com>)
Re: how to force an insert before Raise Exception?  (Taras Kopets <tkopets@gmail.com>)
Re: how to force an insert before Raise Exception?  (Craig Ringer <craig@postnewspapers.com.au>)
Список pgsql-general
Hi.

I made a function that Raise exception with some conditions.
No problem with that, it is the goal.

My problem is that i want to do an INSERT into a log table before to raise
the exception. But RAISE EXCEPTION cancels my Insert.

How to force the insert to not being cancelled please?
Note that i want my exception to be raised , so i can't use:
EXCEPTION WHEN THEN

Thanks for your help.

example :
CREATE OR REPLACE FUNCTION "PrepareTrialLic"(userid integer)
BEGIN;
IF userid = 0 THEN
     --I want to force that insert !!!!!!!!!!!!!!!!!!
     INSERT INTO log_error(caller, description) VALUES('PrepareTrialLic',
'userid is 0');
     RAISE EXCEPTION 'userid can''t be equal to 0';
ENDIF;
END;


--
View this message in context:
http://postgresql.1045698.n5.nabble.com/how-to-force-an-insert-before-Raise-Exception-tp4313283p4313283.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: pg_reorg
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: how to force an insert before Raise Exception?