record lock, NOWAIT and WAIT

for example:

Code:
TOracleSession = class(TComponent)
  private
    FDefaultForUpdateWaitSeconds: integer;
  published
    property DefaultForUpdateWaitSeconds : integer read FDefaultForUpdateWaitSeconds write FDefaultForUpdateWaitSeconds default 0;

{...}
  TOracleDataset = class(TDataSet)
  private
    FForUpdateWaitSeconds: integer;
  protected
    function ForUpdateWait : string;
  published
    property ForUpdateWaitSeconds : integer read FForUpdateWaitSeconds write FForUpdateWaitSeconds default -1;
{...}
function TOracleDataSet.ForUpdateWait : string;
var iWaitSeconds : integer;
begin
iWaitSeconds := FForUpdateWaitSeconds;
if iWaitSeconds < 0 then
   iWaitSeconds := Session.DefaultForUpdateWaitSeconds;
if iWaitSeconds <= 0
then
   result := ' nowait'
else
   result := ' wait ' + IntToStr(iWaitSeconds);
end;

{...}
function TOracleDataSet.FetchRecord =>
{...}
//if LockIt then SQL.Add('for update nowait');
if LockIt then SQL.Add('for update ' + ForUpdateWait);
{...}
//SQL.Add('for update of ' + GetUpdatingAlias + '.' + DataField.FieldName + ' nowait');
SQL.Add('for update of ' + GetUpdatingAlias + '.' + DataField.FieldName + ForUpdateWait);
{...}
      //if EOracleError(E).ErrorCode = 54 then s := dmRecordLocked;
      if (EOracleError(E).ErrorCode = 54) or (EOracleError(E).ErrorCode = 30006) then s := dmRecordLocked;
 
Back
Top