DISCLAIMER: This is legacy code and I simply can't rewrite everything (trust me, I would like to).
I'm trying to execute a legacy Delphi app which uses BDE and DB2, but I simply can't run parametrized querys.
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
Now... Why the QueryB sample doesn't work? I've tryed just about anything I could imagine: using Value
instead of AsString
, calling Prepare
and UnPrepare
, but nothing seems to work. Any ideas?
IMPORTANT: I'm conecting directly via BDE and not using BDE -> ODBC -> DB2 approach.
EDIT: Environment information:
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".
Well, looks like there's no solution for this issue. As pointer by @TOndrej and @DavidG, this QC issue was never solved an no one seems to know how to work around it.
In my case, I will give up and inform my superiors that we can't support DB2 anymore unless we rewrite the application. Anyhow, thanks to everyone that tried to help me.