TADOQuery で上位N項目のみを選択しようとしていますが、クエリをアクティブにするとエラーが発生します。トップパラメータは問題ないように見えますが、実行時にそれを置き換えることができません。「上位 N」で SQL ステートメントを制限しない場合、コードは正常に機能します。
コードの基本的な考え方は次のとおりです。
const SQL_STR = 'SELECT TOP :cnt name from dSomeTable where done = FALSE';
var
dbCon : TADOConnection;
toSolveQry : TADOQuery;
getCnt : TParameter;
names : TField;
threadCnt : Integer;
begin
threadCnt := 3;
dbCon := TADOConnection.Create(nil);
...
dbCon.Open();
toSolveQry := TADOQuery.Create(nil);
toSolveQry.Connection := dbCon;
toSolveQry.SQL.Add(SQL_STR);
toSolveQry.ParamCheck := True;
getCnt := toSolveQry.Parameters.ParamByName('cnt');
getCnt.Value := threadCnt;
toSolveQry.Active := true; //Error here
names := toSolveQry.FieldByName('name');
...
end