Search code examples
sqldelphiparametersnexusdbelevatedb

How do I output the value of a parameter in SQL after it has been inserted?


Is it possible to retrieve the SQL statement with the values of parameters after it has been set and inserted into the SQL component?

SQL Statement:

SELECT * FROM SomeTable
WHERE SomeColumn = :pSomeValue;

Code:

procedure LoadParams(aValue: string);
begin
  Qry.Close;
  Qry.ParamByName('pSomeValue').AsString := aValue;
  MessageDlg(Qry.SQL.Text, mtInformation, [mbOK], 0); // this does not show the value but the parameter name.     
  Qry.Open;
end;

I want to be able to see the statement before it is opened but when I try this now I get the param name instead of the value.


Solution

  • Query parameters are normally substituted in the DBMS, i.e. the values are sent over the connection separately, and not as part of the SQL statement. If you wish to see the SQL and the values together, the DB's logs might help you with that.