2

In continue to this question,when using FireDac, and calling in BeforePost event to a function that calls, Abort, cause a full system abort that breaks the loop that running around that abort.

while not fdOtherQuery.eof do begin
  fdQuery.insert;
  fdquery.fields[0].asstring := fdOtherQuery.fields[0].asstring;
  fdquery.post;
fdOtherQuery.next;
end;

Before post:

procedure TForm1.AzureDayarKriaAdditionsBeforePost(DataSet: TDataSet);
begin
  calculcation;  
end;

procedure calculaction;
begin
  if fdQuery.fields[0].asstring = 0 then abort;
end;

In case the abort in calculation is called, then the

while not fdOtherQuery.eof do begin

is also stoped

Community
  • 1
  • 1
none
  • 4,669
  • 14
  • 62
  • 102

1 Answers1

3

Abort raises a silent exception, which can be caught with try ... except.

while not fdOtherQuery.eof do begin
  fdQuery.insert;
  fdquery.fields[0].asstring := fdOtherQuery.fields[0].asstring;
  try
    fdquery.post;
  except
    on E: EAbort do
    begin
      // log the error (when needed)
    end;
  end;   
  fdOtherQuery.next;
end;
mjn
  • 36,362
  • 28
  • 176
  • 378