Subject 4.3: Little problems with IBOQuery params
Author paulfilmer
Hi all

Bare with me here - I'll try and explain it as easy as possible. This
is probably only of interest to Jason/Helen/et al and anyone who is
having troubles with parameters on IBOQuery component.

I'm using IBO4.3, Borland Interbase v6, Delphi 7, Windows 2000.

I upgraded from 4.1Ia to 4.3 and found some little niggly things that
I had to fix in our query component (extension of TIBOQuery). Things
may be OK now but it would be nice to let people know if they have
similar troubles. I don't know if its because the components have
been tightened up or whether they are bugs in the new IBO.

In summary:
- Query.Params.Clear had to be replaced with Query.Params[i].Clear
- Must also call Query.InternalDataset.Params[i].Clear


** 1 - Clearing Parameters **
Firstly, I used to clear parameters using:
Query.Params.Clear

In IBO4.3 this cleared the list of params, and still left the query
prepared. Not a good move if the code is structured like:
Query.Params.Clear
If not Query.Prepared then
Query.Prepare;
Query.ParamByName(...)... <<< exception would be raised here
Query.Open

Anyhow that was fixed by changing Params.Clear to loop on all params
and call Params[i].Clear. I suspect this was just lazy coding on my
part and it is good that it is now fixed.

** 2 - Boolean Parameters **
Then I found a new problem with boolean fields used as a parameter in
some SQL text. Our boolean fields are typed as a CHAR(1) field type.
The query is something like:
SELECT * FROM MYTABLE
WHERE (FLAGFIELD = :pFLAG)

And we would assign the parameter like:
Query.ParamByName('pFLAG').AsBoolean := True;

The first time the query runs everything is fine. Try
clearing/preparing/opening it again, and it raises an exception on
the Query.open routine when copying the parameter values into
Query.InternalDataset.

It appears that the parameter is valued '-1' in the
TIBODataSet.AssignParamValueToCol() procedure, but ACol (Internal
dataset column) has an .AsString value of '-' (should be '-1' but the
field size is only 1).

This causes a problem when accessing ACol as a smallint as it does
for ftBoolean field types.

I am guessing that the boolean value for true is set as (integer) -1
somewhere in the code. I wouldn't know where too look.

Anyhow I get around this by clearing all the
Query.InternalDataset.Params entries as well in a for loop.


All is working ok so a bit more playing around till I'm happy with
the new version and I can issue a new upgrade of our software.