Subject Re: [IBO] list of values in a parameter
Author l_gilbert_fr
Thank you all for your replies.

The only think why I cannot really use your solutions is I wrote an application many years ago with an user defined database-to-EXCEL export module : The queries are wrote by the users. I'm writing an update to add a selection level so, I can't and I don't want to look in depth how the queries are done. The selection is an another SQL query and could be a single or a multiple selection (a parameter defines the selection type). the link is made by the SELECTION parameter.

I think I can use your idea to manage myself the SELECTION parameter (ie. before to give the query to IBO) : A StringReplace should be the final solution :-)...

Thank you.
Laurent.



--- In IBObjects@yahoogroups.com, Ben Malings <ben.malings@...> wrote:
>
> > I've found it works to build the SQL in the Delphi code, somewhat
> like this:
> >
> > with theQuery do
> > begin
> > Close;
> > SQL.Clear;
> > SQL.Add('select * from the_table where thetable_key in (' +
> > my_StringList.CommaText + ') ' );
> > Open;
> > ...
> > end;
>
> That's OK for integers but it doesn't use parameters, so I wouldn't use
> it for string fields.
> For a stringlist of arbitrary length, something like this should work
> (not tested so excuse any bugs):
>
> qry.SQL.Add('where the_table_key in (:p0');
> qry.Params[0].AsString := my_StringList[0];
> for i := 1 to my_StringList.Count - 1 do begin
> qry.SQL.Add(Format(',:p%d',[i]));
> qry.Params[i].AsString := my_StringList[i];
> end;
> qry.SQL.Add(')');
>