Unix Technical Forum

savepoints

This is a discussion on savepoints within the pgsql Admins forums, part of the PostgreSQL category; --> This is the scenario: Controller function fncCtrl calls function A, function B and function C in that order. Function ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 06:00 AM
Sriram Dandapani
 
Posts: n/a
Default savepoints

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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 06:00 AM
Alvaro Herrera
 
Posts: n/a
Default Re: savepoints

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.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:39 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com