Home > Archive > PostgreSQL Discussion > May 2005 > Re: Locking rows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Locking rows
Tom Lane

2005-05-26, 8:24 pm

"gabriele zelasco" <rubensoda@inwind.it> writes:
> I would like to start a transaction with a sql function.
> When user press "edit" button on my form, i would lock the current row.
> After user has modified data on form, pressing "save" button I would save t=
> he modified row by sql update function and so commit.


This is widely considered a very bad way to design an application.
Consider what happens when the user leaves for lunch, or otherwise
lets the app sit for a long time. See the list archives for prior
discussions of the issue.

But in any case, the answer to your question is to use "SELECT FOR
UPDATE" to retrieve the row. And you can't start a transaction
inside a function, because by definition you'll already be in one.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com