Search Postgresql Archives

Re: how to force an insert before Raise Exception?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux