commit inside a function failing
commit inside a function failing
От:
Suresh Raja <suresh.rajaabc@gmail.com>
Дата:
Hi All:
We are running a function with a loop in it. We tried
commit;
We are getting error with above command. How can i easily commit withing a function.
Thanks,
-SR
Re: commit inside a function failing
От:
Pavel Stehule <pavel.stehule@gmail.com>
Дата:
Hi
2015-01-23 20:56 GMT+01:00 Suresh Raja <suresh.rajaabc@gmail.com>:
Hi All:We are running a function with a loop in it. We triedcommit;We are getting error with above command. How can i easily commit withing a function.
It is not possible in PostgreSQL
Regards
Pavel Stehule
Thanks,-SR
Re: commit inside a function failing
От:
Adrian Klaver <adrian.klaver@aklaver.com>
Дата:
On 01/23/2015 11:56 AM, Suresh Raja wrote: > Hi All: > > We are running a function with a loop in it. We tried > commit; > We are getting error with above command. How can i easily commit > withing a function. Functions do not have transactions inside them. If you are using plpgsql you can use EXCEPTIONS: http://www.postgresql.org/docs/9.3/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING > > > Thanks, > -SR -- Adrian Klaver adrian.klaver@aklaver.com
Re: commit inside a function failing
От:
"ktm@rice.edu" <ktm@rice.edu>
Дата:
On Fri, Jan 23, 2015 at 01:56:53PM -0600, Suresh Raja wrote: > Hi All: > > We are running a function with a loop in it. We tried > commit; > We are getting error with above command. How can i easily commit withing > a function. > > > Thanks, > -SR PostgreSQL functions run within a transaction. You would need to use something like db_link. Regards, Ken
Re: commit inside a function failing
От:
Christopher Browne <cbbrowne@sympatico.ca>
Дата:
The straightforward answer is that stored functions always run *inside* the context of a preexisting transaction, therefore you cannot request a separate transaction from within a stored function.
What you are asking is fairly deeply impossible.