Re: Transactions within a function body - Mailing list pgsql-general

From Bob Henkel
Subject Re: Transactions within a function body
Date
Msg-id fedea56b0810020830p36db6090t13a676beb96c521b@mail.gmail.com
Whole thread Raw
In response to Transactions within a function body  (Reg Me Please <regmeplease@gmail.com>)
Responses Re: Transactions within a function body  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-general
Have you looked at creating a function in perl and creating a new connection? Or using a dblink query which can create a new connection?  These two methods work. I have used them to insert to a log table regardless of the parent transaction being commited or rolled back.
 
A old example I posted of using pl/perl can be found here ->http://www.postgresqlforums.com/forums/viewtopic.php?f=4&t=647
 
The key is opening a new session which using dblink or pl/perl dbi connection will do. This is not ideal as it would be nice if you could just do autonomous transactions, but I find this method works for the cases where you need it.
 
Bob
 
"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.

Thanks."

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Transactions within a function body
Next
From: "Gurjeet Singh"
Date:
Subject: Re: Transactions within a function body