I am attempting to document the SQL calls in a large project without making extensive changes to the code. To start this process, we decided to try to log the DBX queries that are executed.
So I have:
procedure TRService.GetContactInfo(sessionid: String; msrno: Integer);
var
SQL: String;
qryContact: TSQLQuery;
username: String;
begin
qryContact := TSQLQuery.Create(nil);
qryContact.SQLConnection := TSQLConnection1;
qryContact.SQL.Add('select name, address');
qryContact.SQL.Add('from contact');
qryContact.SQL.Add('where (msrno = :msrno)');
qryContact.ParamByName('msrno').AsInteger := msrno;
{$ifdef LOGSQL}
SQL := qryContact.???
LogSQL(SQL);
// CallNewServer(SQL);
{$else}
qryContact.Open;
{$endif}
end;
end;
When the LogSQL function is called, I want it to log
'Select * from contact where (msrno = 12345)'
Which property '.???' of the TSQLQuery can I use to give me the SQL string with the parameters already replaced with values? Ideally I want to do this before the qryContact.open
, because in a future version, the qryContact.open
will be replaced by a call to a different server.