Re: How do I save data and then raise an exception? - Mailing list pgsql-general

From Gurjeet Singh
Subject Re: How do I save data and then raise an exception?
Date
Msg-id 65937bea0810022015y6bf2bb16v40ae503cbb2cb581@mail.gmail.com
Whole thread Raw
In response to Re: How do I save data and then raise an exception?  ("Jaime Casanova" <jcasanov@systemguards.com.ec>)
List pgsql-general
On Fri, Oct 3, 2008 at 7:41 AM, Jaime Casanova <jcasanov@systemguards.com.ec> wrote:
On Thu, Oct 2, 2008 at 8:44 PM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Rob Richardson wrote:
>
>> Here's what I need to do:
>>
>> IF query_check_fails THEN
>>     UPDATE some_table SET some_value = 0 WHERE some_condition_is_true;
>>     RAISE EXCEPTION 'Look, you idiot, do it right next time!';
>> END;
>>
>> I need the update to work, but I need to raise the exception so the C++
>> code recognizes the error.  How can I do both?
>
> You need an autonomous transaction, which Postgres does not support
> directly but you can implement using dblink or a plperl function that
> connects back to the database.
>

what about RAISE NOTICE?

NOTICE wouldn't rollback any part of the transaction! OP needs mixed COMMIT success in the same transaction.

--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB      http://www.enterprisedb.com

Mail sent from my BlackLaptop device

pgsql-general by date:

Previous
From: "Jaime Casanova"
Date:
Subject: Re: How do I save data and then raise an exception?
Next
From: "Gurjeet Singh"
Date:
Subject: Re: How do I save data and then raise an exception?