On Tuesday, April 19, 2011 6:39:23 am giova wrote:
> 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
Why not? From the docs:
"When an error is caught by an EXCEPTION clause, the local variables of the PL/pgSQL function remain as they were when the error occurred, but all changes to persistent database state within the block are rolled back. As an example, consider this fragment: "
And instead of RAISE EXCEPTION use RAISE NOTICE in the exception clause.
>
> Thanks for your help.
>
--
Adrian Klaver
adrian.klaver@gmail.com