Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi everyone, I have a record loc

Status
Not open for further replies.

ErcanPOLAT

Programmer
Feb 28, 2003
2
TR
Hi everyone,

I have a record locking problem with the InterBase. I want to lock current row when a user edit it and I want to raise an exception like "this record locked by user A" when another user try to edit same row. I am using Delphi7 and IBX objects. If Params property of IbTransaction is empty ,I can see an deadlock exception on updating the record. But I have to use READCOMMITTED. But this time, application gives no exception. How can I lock a row. Thanks.
 
You can't "lock" a row... The only thing you can do is do a dummy update, then other users will get the deadlock exception. But you won't know what user locked the row...

Besides, why would you lock?

Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
 
Thanks Martijn. You asked me why I would lock . With normal methods, users makes their changes and then update. If another user change same record before, application gives user a deadlock exception. So, User have to cancel editing and rollback. My aim is to warn user about row status before editing.
What do you recommend me.
 
I was just wondering if this deadlock situation happens a lot...

Do you need to tailor for the deadlock, or for the warning - that's the question.

I guess it depends on taste - some people like to handle the problem afterwards (deadlock), some people like to handle it before it occurs.

Anyway, you will always get a deadlock situation - even if you "lock" the row... Perhaps you can use a flag column to indicate someone is changing it - however, make sure to reset the flag afterwards, and how do you handle client-side crashes?

Food for thought, right?
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
 
Use the security features of Interbase, define user groups and grant different rights.
Maybe use different tables. Why on earth 20 people at the same time would update the same field? What is the probability that this happens?
In Interbase you can grant rights on field level. Delphi will come with the standard message sent by Interbase: Insufficient sql rights for operation. No permission for update/write access to table TableName Steven van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top