Table Locking

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Rober Watson
Posts: 7
Joined: Tue 02 Sep 2008 16:14

Table Locking

Post by Rober Watson » Tue 21 Oct 2008 15:04

TMyQuery

Multiple use system

Writing an app in which an email address will be used for the login.
Very low security and the owner understands this.

Therefore email addresses must be unique. On a person adding themselves to the database, I need to check to see if that email address exits and if so, deny its duplication. I therefore need to LOCK the table while I do the search. I'm new to SQL, but what I think I need to do is.

Close Query
Open Query in "Read Locked Mode" ... lock it so anyone can read it, but
not write to it
Do my email checking
Do my transaction if no duplicate
Unlock it

I see a Query.LockTable capability but I cannot find the appropriate
value of the lock ... I tried ltReadLock which did not work.

I would appreciate any help.

Thanks,
Bob Watson

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Wed 22 Oct 2008 08:14

For this purpose you can execute the SELECT ... WHERE MAILE = '' FOR UPDATE statement (in transaction) or use the Lock method. For more information please refer to the Lock Demo in MyDAC demo project.

Post Reply