I have a SQL Query something like
select * from mytable where field in ('a', 'b' ,'c') where I need to send 'a', 'b' 'c' as a parameter. I tried a few variations, array, string, but either get no response or application execption.
How can I accomplish this?
As a temporary workaround I replaced the string in the query but not ideal solution...
passing parameters for where in clause
Re: passing parameters for where in clause
To pass values to the query 'a', 'b', 'c' you can use macros :
or apply the parameter in the following way :
Code: Select all
...
OraQuery.SQL.Text: = 'select * from mytable where field in (&list)';
OraQuery.MacroByName('list').AsString := 'a'', ' + '''b'', ' + '''c';
Code: Select all
OraQuery.SQL.Text := 'select * from mytable where InStr(:list, ''_''||field||''_'') > 0';
OraQuery.ParamByName('list').AsString := '_a_b_c_';