Im trying to log sql statements, using TZSQLMonitor, that are generated after an Edit statement on the query.
See the code below please:
Code: Select all
ehConnectIbSqlServer;
with qIbGetOccupiedCompartments do begin
Open;
First;
while not Eof do begin
Edit;
FieldByName('OrderId').AsString := '123';
dbIbSql.StartTransaction;
ApplyUpdates;
dbIbSql.Commit;
Next;
end;
end;
ehDisConnectIbSqlServer;
Code: Select all
procedure TfrmMain.monIbSqlLogTrace(Sender: TObject; Event: TZLoggingEvent);
begin
ehLogSqlEvent(lbIbSqlMon, Event);
end;
procedure TfrmMain.ehLogSqlEvent(lbListBox : TlistBox; Event : TZLoggingEvent);
begin
with lbListBox.Items do begin
Add('Protocol...: ' + Event.Protocol);
Add('Message....: ' + event.Message);
Add('Error Code.: ' + IntToStr(Event.ErrorCode));
Add('Error Msg..: ' + Event.Error);
Add('TimeStamp..: ' + DateToStr(Event.Timestamp));
Add('');
end;
end;
Part of the log looks like this:
Protocol...: interbase-6
Message....: CONNECT TO "W:\SQLDB\OrderProcessingEX\DB\nlstore.GDB" AS USER "sysdba"
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006
Protocol...: interbase-6
Message....: TRANSACTION STARTED.
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006
Protocol...: interbase-6
Message....: SELECT * FROM COMPARTMENTS WHERE ORDERID<>'0' ORDER BY COMP_NO
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006
Protocol...: interbase-6
Message....: TRANSACTION COMMIT
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006
Only the transaction commit is logged but not the actual update-sql-statement. The code works fine as all records are updated.
Any help would be appreciated.
Regards, Erik