免責事項:これはレガシー コードであり、すべてを書き直すことはできません (信頼してください。やりたいと思います)。
BDE と DB2 を使用する従来の Delphi アプリを実行しようとしていますが、パラメータ化されたクエリを実行できません。
QueryA.SQL.Text := 'select count (*) from syscat.tables where tabname = ''Foo''';
QueryA.Open; // works as expected
QueryB.SQL.Text := 'select count (*) from syscat.tables where tabname = :name';
QueryB.ParamByName('name').ParamType := ptInput;
QueryB.ParamByName('name').DataType := ftString;
QueryB.ParamByName('name').AsString := 'Foo';
QueryB.Open; // Error: "Operation not applicable"
QueryC.SQL.Text := 'select count (*) from syscat.tables where tabname = :name';
QueryC.ParamByName('name').ParamType := ptInput;
QueryC.ParamByName('name').DataType := ftString;
QueryC.ParamByName('name').Clear;
QueryC.Open; // Surprisingly, no erros here
さて... QueryB サンプルが機能しないのはなぜですか? Value
の代わりに を使用し、とAsString
を呼び出しましたが、何も機能していないようです。何か案は?Prepare
UnPrepare
重要:私は BDE 経由で直接接続しており、BDE -> ODBC -> DB2 アプローチは使用していません。
編集:環境情報:
Delphi Version: 5, UpdatePack 1
BDE: 5.01
OS: Windows 7 SP1, x64
D:\SQLLIB\BIN>db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL09052" with
level identifier "03030107".
Informational tokens are "DB2 v9.5.201.346", "s080911", "WR21421", and Fix Pack "2a".
Product is installed at "D:\SQLLIB" with DB2 Copy Name "DB2COPY1".