I have an oracledataset with which i want to run queries.
Setting the sql is no problem, but when the sql contains variables i get stuck.
What is the correct way to determine and add variables to an oracledataset from a query set at runtime?
I tried using TParam.ParseSQL, but when i add the params i find that way i get an ORA error about an incorrect variable name.
The query:
SELECT
*
FROM
ecare.wens wns
WHERE
Upper(wns.resources) like '%' || :RESOURCE || '%'
Setting the sql is no problem, but when the sql contains variables i get stuck.
What is the correct way to determine and add variables to an oracledataset from a query set at runtime?
I tried using TParam.ParseSQL, but when i add the params i find that way i get an ORA error about an incorrect variable name.
Code:
p := TParams.Create;
try
p.ParseSQL(OracleDataSet.SQL.Text, true);
for i := 0 to Pred(p.Count) do
begin
s := InputBox('Enter value for variable', p[i].Name, '');
OracleDataSet.DeclareVariable(p[i].Name, otString);
OracleDataSet.SetVariable(p[i].Name, s);
end;
finally
p.Free;
end;
OracleDataSet.Open; // <- ORA-01745 Invalid variable name
The query:
SELECT
*
FROM
ecare.wens wns
WHERE
Upper(wns.resources) like '%' || :RESOURCE || '%'