Is it not possible to define transactions inside of a function?
I guess you can do
BEGIN WORK;
select my_function()
COMMIT;
instead of defining the function
CREATE FUNCTION my_function()...
BEGIN
BEGIN WORK;
....
COMMIT;
END;
but what if you would like to do
CREATE FUNCTION my_function()...
BEGIN
.... do stuff.....
BEGIN WORK;
....
COMMIT;
do more stuff ....
END;