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

From Adrian Klaver
Subject Re: how to force an insert before Raise Exception?
Date
Msg-id 201104190747.22780.adrian.klaver@gmail.com
Whole thread Raw
In response to how to force an insert before Raise Exception?  (giova <giovainstall2@yahoo.fr>)
List pgsql-general

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

pgsql-general by date:

Previous
From: giova
Date:
Subject: how to force an insert before Raise Exception?
Next
From: Taras Kopets
Date:
Subject: Re: how to force an insert before Raise Exception?