You'll have to begin the transaction before the function is run (implicit
within a query if not in a xact). End the transaction after the function
returns. If the function does a RAISE EXCEPTION ''I don't like that'', then
the transaction is aborted during the function. Again, within a query (which
triggers your function), a transaction is begun implicity if a transaction is
not begun explicity beforehand with BEGIN.
On Thursday 18 January 2001 12:16, Zolof wrote:
> This code doesn't work. I use Begin Work to start a transaction but BEGIN
> is a PL/pgSQL command so I have a parse error when executing it.
>
> CREATE FUNCTION a () RETURNS int4 AS '
> BEGIN
> BEGIN WORK;
> COMMIT WORK;
> return 1;
> END;
> ' LANGUAGE 'plpgsql';
>
> What's wrong ????
--
-------- Robert B. Easter reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------