Catching exception from locking mode access

Context : Delphi 4 UP3, Oracle 8.0.5, DOA 3.3
My OracleDataSet.LockingMode property is set to 'lmLockImmediate'. When concurrent accesses append on the same record of my dataset, a message box is displayed. I know I can change the message... OK. But I would like an exception to be triggered... an exception (EOracleError) catchable with try...except... instruction. An Oracle error is generated because OnTranslateMessage event is triggered with an error code (ORA-00054). But this is not an Exception.
How an exception can be triggered in that case ? How can I catch this event differently ?
Thanks for your answers.
 
The exceptions that occur during standard TDataSet operations like Edit, Post, Delete, and so on, are all EDatabaseErrors. You can handle such an exception as usual:

Code:
try
  OracleDataSet.Edit;
except
  on E: EDatabaseError do ShowMessage(E.Message);
end;

If you want to explicitly test for a locking conflict, you have to compare the message of the exception to dmRecordLocked, which is the string constant that is used for the exception message by a TOracleDataSet for a locking conflict. Unfortunately the EDatabaseError does not have an ErrorCode property like the EOracleError, so you can't simply check for ORA-00054.

------------------
Marco Kalter
Allround Automations
 
Thanks Marco !
I've checked an EDatabaseError in try...except instruction and I've compared E.Message to dmRecordLocked.
It looks OK.

Pascal Cadot.
 
Back
Top