1

I have a runtime created query that may or may not need some specific params to be used more than once. If I use ParamByName in a query like

select field1 
from table1 
where field2 = :a 
and field2 in(select field3 from table2 where field3 = :a)

What happens when I call

MyQuery.ParamByName('a').AsString:= 'something';

Will both params be filled?

Miguel E
  • 1,316
  • 2
  • 17
  • 39
  • The answer would be no, you'll need to use 2 parameters... [Related post](http://qc.embarcadero.com/wc/qcmain.aspx?d=1654) – whosrdaddy Nov 05 '15 at 19:30
  • Or loop through all parameters and assign them depending on their names. – Abelisto Nov 05 '15 at 19:33
  • 2
    What did you observe when you tested it? – Rob Kennedy Nov 05 '15 at 20:28
  • It depends on the data access components you're using. `TAdoQuery`, for instance, requires you to assign the value multiple times. The Advantage `TAdsQuery`, on the other hand, allows you to set the parameter once and it will populate all uses of that parameter in the SQL statement. So, as @Rob asked, what happens when you try it with the particular DB access components you're using? (Taking two minutes to write a quick test application is extremely helpful, and most times gives you an answer a thousand times quicker than posting here, formatting, and waiting.) – Ken White Nov 05 '15 at 23:31

0 Answers0