Search Postgresql Archives

Re: Problem compiling function with BEGIN WORK; COMMIT WORK;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/04/2010 9:07 AM, Andre Lopes wrote:
Hi,

I need to use the BEGIN WORK; and COMMIT WORK; to lock a table when I'am
doing a SELECT and UPDATE operation.

PostgreSQL's server-side functions do *not* support transaction management. They're functions that're used inside an existing transaction.

However, if you do not explcitly BEGIN a transaction before calling your function, the statement your function runs in will start and stop its own transaction. In other words, these two things are equivalent:

BEGIN;
SELECT my_function();
COMMIT;

and

SELECT my_function();

(outside an existing transaction)



Because your function is *always* inside a transaction, it can always acquire locks and the like. It doesn't need to explicitly start a transaction first.

--
Craig Ringer


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux