Thread: transactions and cursors......

transactions and cursors......

From
Chris Pesko
Date:
Can I put transactions and cursors into functions?  As soon as I put BEGIN;
and COMMIT; wrapping an insert statement within a function, I get
errors.  Do these programs need to reside outside of the database?


Re: transactions and cursors......

From
"Dan Langille"
Date:
On 27 Feb 2002 at 9:30, Chris Pesko wrote:

> Can I put transactions and cursors into functions?

No.

> As soon as I put BEGIN;
> and COMMIT; wrapping an insert statement within a function, I get errors.
> Do these programs need to reside outside of the database?

AFAIK, yes.
--
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples


Re: transactions and cursors......

From
"Arguile"
Date:
Chris Pesko writes:
> Can I put transactions and cursors into functions?  As soon as I
> put BEGIN;
> and COMMIT; wrapping an insert statement within a function, I get
> errors.  Do these programs need to reside outside of the database?

Pg doesn't supported nested transactions or save points (yet). So you can't
have transactional control inside plpgsql functions.


Cursors will depend on what version you're running. See chapter 23.7 of the
7.2 documentation for using cursors inside functions.

http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql-cursors.
html