Search code examples
delphiparametersbde

Pass parameter by "in" Delphi


I need to pass a parameter to a SQL in Delphi using BDE to be using an "in", the example below:

select * from customers where id in (:p_in)

I need to pass: p_in a list of customers. But Query.ParamByName.('p_in').AsString: = '1, 2,3 ', and it did not work .. Will have to make an array? or passed by AsVariant?


Solution

  • try this :

    p_in  : String ;
    
    for i := 0 to Customerlist.count do
       p_in := p_in +Customerlist[i] + ','; 
    
    MyQuery.text := 'select * from customers where id in (' + p_in  + ' )' ;