procedure TdmTemporary.ExecQueryIDs(const AParamName: string; Idents: string); var I, P, MaxLengthIDs: Integer; S: string; begin if AParamName = '' then MaxLengthIDs := 1472 else MaxLengthIDs := 32732; S := ''; while Idents <> '' do begin P := -1; if Length(Idents) > MaxLengthIDs then for I := MaxLengthIDs-16 to Length(Idents) do if Idents[I] = ',' then begin P := I; Break; end; if P > 0 then begin if AParamName = '' then begin if S = '' then S := qSelector.SQL.Text; qSelector.SQL.Text := Format(S, [Copy(Idents, 1, P-1)]); end else qSelector.ParamByName(AParamName).AsString := Copy(Idents, 1, P-1); qSelector.ExecQuery; Delete(Idents, 1, P); end else begin if AParamName = '' then begin if S = '' then S := qSelector.SQL.Text; qSelector.SQL.Text := Format(S, [Idents]); end else qSelector.ParamByName(AParamName).AsString := Idents; qSelector.ExecQuery; Break; end; end; end; |