hace años hice estas rutinas que aún tiro de ellas:
Código Delphi
[-]
uses CheckLst, Classes ;
function QuotedList( Items: TStrings):string;
function QuotedListChklb( ctrl:TCheckListBox;const SoloChecked:Boolean = True):string;
....
function QuotedListchklb( ctrl:TCheckListBox;const SoloChecked:Boolean = True):string;
var i:integer;
begin
result := '';
with ctrl do
for i:= 0 to Items.Count-1 do
if SoloChecked then
begin
if Checked[i] then
Result := Result +QuotedStr(Items[i])+',';
end
else
Result := Result +QuotedStr(Items[i])+',';
if Length(Result)>0 then
Delete(Result,Length(Result),1);
end;
function QuotedList( Items: TStrings):string;
var i:integer;
begin
result := '';
for i:= 0 to Items.Count-2 do
Result := Result +QuotedStr(Items[i])+',';
if Items.count > 0 then
Result := Result + quotedstr(Items[Items.count-1]);
end;
Yo quitaría el parámetro y concatenaría con la salida de quotedList, algo así:
Código Delphi
[-]
IBQuery1.SQL.Text := 'SELECT D.DOCTO_CC_ID,D.FOLIO,................ '+
'.....................................................................................'+
'left outer join SALDO_CARGO_CC_S ( D.DOCTO_CC_ID,D.FECHA,0,'N') s '+
'on(D.docto_cc_id=cargo_id) '+
'WHERE ( D.CONCEPTO_CC_ID = 4 ) and (s.saldo_cargo<>0) and '+
'(D.clave_cliente in ('+QuotedList(ListBox.Items)+'))';
Saludos