For Tom Lane (Msg-ID: <IH5LKE$51FADB513BB3BB27F05E974EBE1A0558@libero.it>)

From: "rubensoda(at)inwind(dot)it" <rubensoda(at)inwind(dot)it>
To: maillog_inc(at)heuft(dot)intern
Cc: pgsql-general(at)postgresql(dot)org
Subject: For Tom Lane (Msg-ID: <IH5LKE$51FADB513BB3BB27F05E974EBE1A0558@libero.it>)
Date: 2005-05-27 14:57:50
Message-ID: 20050531144201.9728.qmail@heuft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> "gabriele zelasco" <rubensoda(at)inwind(dot)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
>

Thanks for answer Tom

"Consider what happens when the user leaves for lunch"

Well, I've already thought about it.But I'm working with
VS2003 and disconnected dataset.. so when user edit data
he's modifying an "old" disconnected row, while real updated row
is in the database..
So my strategy would be (as I already written):

1. refresh data recalling current row from database to the form's fields
2. lock the row
3. update modified data in the database through stored procedure (function)
4. commit and unlock the row

Have you another idea that could work better with disconnected objects ?

the answer to your question is to use "SELECT FOR UPDATE" to retrieve the row

Well, I've created a sql function with just sql command :
select * from table where condition FOR UPDATE
but it doesn't lock the row !

If I write "begin;" before command , inside function,
I get the error (begin is not allowed...)

So what I have to do if I would lock a row from inside vb net code?
Thanx in advance

____________________________________________________________
Navighi a 4 MEGA e i primi 3 mesi sono GRATIS.
Scegli Libero Adsl Flat senza limiti su http://www.libero.it

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Browse pgsql-general by date

  From Date Subject
Next Message Shelby Cain 2005-05-27 15:30:57 Re: Visual Studio 2005 .Net -> Npgsql -> Postgresql
Previous Message Jeff Trout 2005-05-27 14:14:03 Re: Just a crazy idea!