Skip site navigation (1) Skip section navigation (2)

Re: Transactions within a function body

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Dennis Brakhane <brakhane(at)googlemail(dot)com>
Cc: Reg Me Please <regmeplease(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Transactions within a function body
Date: 2008-10-02 00:34:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-hackers
Dennis Brakhane escribió:
> On Wed, Oct 1, 2008 at 5:54 PM, Reg Me Please <regmeplease(at)gmail(dot)com> wrote:
> > Hi all.
> >
> > Is there a way to have (sub)transactions within a function body?
> > I'd like to execute some code (a transaction!) inside a function and later
> > decide whether that transaction is to be committed or not.
> You could issue a "SAVEPOINT name". If at the end you don't want your
> changes to apply, you can issue a "ROLLBACK to name"

Actually you can't use SAVEPOINT nor ROLLBACK TO within a function.  In
PL/pgSQL you can use EXCEPTION blocks (if you don't like the changes,
just do a RAISE EXCEPTION, and the exception block is run).

Alvaro Herrera                      
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to


pgsql-hackers by date

Next:From: Hitoshi HaradaDate: 2008-10-02 01:16:47
Subject: Re: Common Table Expressions (WITH RECURSIVE) patch
Previous:From: Aidan Van DykDate: 2008-10-02 00:17:40
Subject: Re: Block-level CRC checks

pgsql-general by date

Next:From: Gurjeet SinghDate: 2008-10-02 01:22:56
Subject: Re: Fwd: Has anyone built pgbash-7.3 against postgreSQL-8.3?
Previous:From: Harvey, Allan ACDate: 2008-10-01 23:32:15
Subject: Re: inserting only new rows from csv file

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group