From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | giova <giovainstall2(at)yahoo(dot)fr> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to force an insert before Raise Exception? |
Date: | 2011-04-21 06:45:38 |
Message-ID: | 4DAFD292.2050609@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 19/04/11 21:39, 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
You can't have part of a transaction cancelled without cancelling all of
it. The INSERT is part of the transaction.
If you really need to insert a record in a log table before rolling back
a transaction, you need to use dblink to do the insert in another
transaction.
Personally, I'd enable PostgreSQL's CSV logging and then process the log
files, so you can include your logging info in the Pg logs. Using
logging tables will be way more hassle than it's worth.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2011-04-21 07:00:03 | Re: Questions about Partitioning |
Previous Message | Toby Corkindale | 2011-04-21 06:22:24 | Poor performance of btrfs with Postgresql |