On Mon, 2003-12-15 at 22:43, Jenny Zhang wrote:
> Another question is, I've read that "Each PL/pgSQL function is
> automatically treated as a single transaction
> by Postgres" at http://www.geocrawler.com/archives/3/6/2002/6/0/9050299/
> is it still true? Even though the shopping_cart function calls A and A
> has BEGIN and COMMIT in it, pgsql won't commit till all the shopping_cart is done?
It is true. If no transaction is already in progress, each statement is
a transaction in itself (or begins a transaction if autocommit is off).
Therefore any function must necessarily execute inside a transaction.
You cannot use BEGIN in a PL/pgSQL function to begin a transaction,
since a transaction is already in progress. In PL/pgSQL, BEGIN marks
the start of the executed code (and follows any declarations).
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"The fear of the LORD is the instruction of wisdom, and
before honour is humility." Proverbs 15:33