Re: [GENERAL] ROLLBACK in a function

2010-05-24 Thread Ken Winter
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Craig Ringer > Sent: Sunday, May 23, 2010 8:48 PM > To: Ken Winter > Cc: PostgreSQL pg-general List > Subject: Re: [GENERAL] ROLLBACK in a funct

Re: [GENERAL] ROLLBACK in a function

2010-05-23 Thread Craig Ringer
On 24/05/10 02:51, Ken Winter wrote: How can I write a PL/PgSQL function that rolls back every database change it has done? Have it raise an exception, causing the surrounding transaction to terminate with an error. Another function calling yours can still catch the exception and handle it,

[GENERAL] ROLLBACK in a function

2010-05-23 Thread Ken Winter
How can I write a PL/PgSQL function that rolls back every database change it has done? I'm about to write a set of database test functions. Each function needs to do some INSERT, UPDATE, or DELETE actions, test whether they had their intended effect, and then roll back the test changes to rest