Page 1 of 1

Table Locking

Posted: Tue 21 Oct 2008 15:04
by Rober Watson
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

Posted: Wed 22 Oct 2008 08:14
by Challenger
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.