Page 1 of 1
is record locked?
Posted: Thu 02 Dec 2010 09:12
by EarlyBird
Hello,
In my multiuser application i need to check whether a record is being edited by user.
I need this before a other user can start to edit the record.
I whant to show a message that the record is in use by a user.
How can i do this?
Thanks for help
EarlyBird
Posted: Thu 02 Dec 2010 10:15
by AlexP
hello,
To do this you can use the TOraQuery.LockMode and TOraQuery.CheckMode properties, for example:
OraQuery1.LockMode := lmLockImmediate;
OraQuery1.CheckMode := cmException;
in this case users will get an error message when trying to modify a record that was used already.
For more information please see the TOraDataSet.LockMode Property and the TOraDataSet.CheckMode Property topics in the ODAC help.
Posted: Thu 02 Dec 2010 11:20
by EarlyBird
Hi,
thanks for quick response.
I tryed your solution.
It works .
But i need a little more information for the User.
Is there a event fired if i try to edit a locked record?
At the moment i get no message.
I only can“t edit the record.
(Thats good)
If the first user has finished editing the record and then i try to edit the record i get a message:"Record was changed by another user."
Is it possible to get my own message for this.
And last: is it possible to refresh only the changed record automaticliy?
Thanks for help
Posted: Thu 02 Dec 2010 12:44
by AlexP
To create your own error message you can use the OnEditError event, for example
procedure TForm1.OraQuery1EditError(DataSet: TDataSet; E: EDatabaseError;
var Action: TDataAction);
begin
ShowMessage('Your error message');
Action:=daAbort;
end;
is it possible to refresh only the changed record automaticliy
You can use the RefreshRecord property like
OraQuery1.RefreshRecord := roBeforeEdit;