Re: savepoints

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Sriram Dandapani <sdandapani(at)counterpane(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: savepoints
Date: 2006-04-12 17:29:47
Message-ID: 20060412172947.GF26756@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Sriram Dandapani wrote:
> This is the scenario:
>
>
>
> Controller function fncCtrl calls function A, function B and function C
> in that order.
>
> Function A needs a savepoint to prevent errors from undoing work that
> needs to be committed regardless of errors in function B or C
>
> Is there a way to define a generic savepoint that any errors in B or C
> will rollback to.

What you can do is to have fncCtrl like this:

BEGIN
perform A();

BEGIN
perform B();
perform C();
EXCEPTION WHEN ...
-- here, either B or C failed
END
END

If B or C fail, the changes made by A will persist.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

  • savepoints at 2006-04-12 17:22:26 from Sriram Dandapani

Browse pgsql-admin by date

  From Date Subject
Next Message Sriram Dandapani 2006-04-12 18:05:52 WAL file naming after postmaster restart
Previous Message Sriram Dandapani 2006-04-12 17:22:26 savepoints