Hello, I'm using UniSQLmonitor to get the SQL statement will send to the database.
I get the text like
update "PESSOA" set
"PESS_NOME" = :1
where
"PESS_ID" = :2
:1(String[9],IN)='CUSTOMER1'
:2(Integer,IN)=-1
I'd like to get the SQL compatible to run in the DataBase, like
update "PESSOA" set
"PESS_NOME" = 'CUSTOMER1'
where
"PESS_ID" = -1
is there any way to get the SQL command like this?
Thanks
UniSQLMonitor Event OnSql - Param Text
Hello,
In order to retrieve an SQL with already pasted parameter values, you should write your own parser. The following sample demonstrates one of possible ways to realize such parser:
In order to retrieve an SQL with already pasted parameter values, you should write your own parser. The following sample demonstrates one of possible ways to realize such parser:
Code: Select all
procedure TForm1.UniSQLMonitor1SQL(Sender: TObject; Text: String;
Flag: TDATraceFlag);
var
i: integer;
s: string;
begin
if (Sender is TCustomDADataSet) and (Text EmptyStr) then
begin
s:= TCustomDADataSet(Sender).FinalSQL;
for i:= 0 to TCustomDADataSet(Sender).ParamCount -1 do
begin
case TCustomDADataSet(Sender).Params.DataType of
ftInteger, ftFloat: s := StringReplace(s, ':'+TUniQuery(Sender).Params.Name, TUniQuery(Sender).Params.Value, [rfReplaceAll]);
ftString:s := StringReplace(s, ':'+TUniQuery(Sender).Params.Name, ''''+TUniQuery(Sender).Params.Value+'''', [rfReplaceAll]);
end;
end;
Text := s;
end;
showMessage(Text);
end;