From: | Christopher Browne <cbbrowne(at)acm(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Transaction Handling in pl/pgsql |
Date: | 2005-07-12 19:14:29 |
Message-ID: | m3u0iz25wq.fsf@mobile.int.cbbrowne.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I am trying to get a better understanding of how transactions work in
> pl/pgsql functions. I found the following text in the help:
> "It is important not to confuse the use of BEGIN/END for grouping statements
> in PL/pgSQL with the database commands for transaction control. PL/pgSQL's
> BEGIN/END are only for grouping; they do not start or end a transaction"
> but I am still a bit confused.
>
> Suppose I have a function that will be called from an application. Will all
> the statements in the function be rolled back if the last one generates an
> exception? or do I need to add code to a function to make that happen?
pl/pgsql code always runs *inside a transaction*.
As a result, if you roll something back, all of the effects of code
inside the transaction will be rolled back.
So you don't need to do anything special for things to roll back.
--
let name="cbbrowne" and tld="acm.org" in String.concat "@" [name;tld];;
http://cbbrowne.com/info/rdbms.html
Rules of the Evil Overlord #153. "My Legions of Terror will be an
equal-opportunity employer. Conversely, when it is prophesied that no
man can defeat me, I will keep in mind the increasing number of
non-traditional gender roles." <http://www.eviloverlord.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Roman Neuhauser | 2005-07-12 19:46:08 | Re: Update more than one table |
Previous Message | Scott Marlowe | 2005-07-12 19:09:45 | gborg borked again? |