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?