Thanks a lot,Nikki's solution is what I think about,but this may lost some
efficiency,maybe this is the only way.
Mario's solution is more easy,but there something hard to control,somebody
will just open the window,displaying the data,but he will never modify the
data,that will resist other client to view the same data.
thanks again

2006/12/6, Mario Frasca <[EMAIL PROTECTED]>:

hongdong wrote:

> I just have a base question:
> assume user A and user B now both connection to a same database and
> both of
> them want to update a  same record,but only one is allowed
> in  this condition:
> A begin to browse the data in a client application,and load rowid into
> GUI
> and keep it in memory.
> B update the record which A want to update
> A now used the id stored in memory to update the same record
> now it's wrong.
> anyone can give me advice how to avoid this and keep the operation is
> effient
> thanks!
>
this sounds like shared and exclusive locks.
A wants a shared lock and possibly upgrade it.
B wants an exclusive lock.

when A starts first:
once A gets its shared lock, B cannot receive an exclusive lock and goes
in standby.
A upgrades its lock to an exclusive lock (there are reasons not to start
asking for a shared lock if you know from the beginning that you're
going to need an exclusive lock).
A releases the lock.
B finally gets in.

notice that if both A and B start asking a shared lock, you'll get in
trouble...  someone must be allowed to break locks and oblige clients to
rollback.

can't point you to english literature, but I'm sure Wikipedia contains
useful hints.

ciao,
MF


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]

-----------------------------------------------------------------------------


Reply via email to