Re: Savepoint/Rollback in functions

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Scott Petersen <scottpetersen(at)softhome(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Savepoint/Rollback in functions
Date: 2006-03-14 23:11:18
Message-ID: 20060314231118.GB8263@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Scott Petersen wrote:

Hi,

> Question 1: does pg/psql functions allow "SAVEPOINT/ROLLBACK"
> functionality? (if so how?)

Yes. However, you cannot use that syntax directly. You rather use it
by establishing EXCEPTION clauses in BEGIN/END blocks. Upon entering
any BEGIN/END block which has an EXCEPTION clause, an implicit SAVEPOINT
is executed. If any exception (read: error) is found while executing
the block, the savepoint will be automatically rolled back and control
passed to the EXCEPTION block.

HTH,

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message John DeSoi 2006-03-15 01:11:32 Re: Copying a row within table
Previous Message Scott Petersen 2006-03-14 22:41:32 Savepoint/Rollback in functions