how to force an insert before Raise Exception? - Mailing list pgsql-general

From giova
Subject how to force an insert before Raise Exception?
Date
Msg-id 1303220363098-4313283.post@n5.nabble.com
Whole thread Raw
Responses Re: how to force an insert before Raise Exception?
Re: how to force an insert before Raise Exception?
Re: how to force an insert before Raise Exception?
List 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 by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: pg_reorg
Next
From: Adrian Klaver
Date:
Subject: Re: how to force an insert before Raise Exception?