pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Sriram Dandapani <sdandapani@counterpane.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: savepoints
Date: Wed, 12 Apr 2006 13:29:47 -0400
Message-ID: <20060412172947.GF26756@surnet.cl> (raw)
In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF03EF4740@ca-mail1.cis.local>
References: <6992E470F12A444BB787B5C937B9D4DF03EF4740@ca-mail1.cis.local>

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.



view thread (2+ messages)

Message-ID: <20060412172947.GF26756@surnet.cl>
Permalink:  ../20060412172947.GF26756@surnet.cl/
Also on:    postgresql.org/message-id/20060412172947.GF26756@surnet.cl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: alvherre@commandprompt.com, sdandapani@counterpane.com
  Subject: Re: savepoints
  In-Reply-To: <20060412172947.GF26756@surnet.cl>
  References: <6992E470F12A444BB787B5C937B9D4DF03EF4740@ca-mail1.cis.local> <20060412172947.GF26756@surnet.cl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox