Subject | Re: [IBO] 4.3: Little problems with IBOQuery params |
---|---|
Author | Nando Dessena |
Post date | 2003-11-20T08:22:40Z |
Paul,
p> Bare with me here - I'll try and explain it as easy as possible. This
p> is probably only of interest to Jason/Helen/et al and anyone who is
p> having troubles with parameters on IBOQuery component.
here, here. :-)
p> I upgraded from 4.1Ia to 4.3 and found some little niggly things that
p> I had to fix in our query component (extension of TIBOQuery). Things
p> may be OK now but it would be nice to let people know if they have
p> similar troubles. I don't know if its because the components have
p> been tightened up or whether they are bugs in the new IBO.
IBO 4.3 has had some bugfixing in the area of parameters and preparing
in TIBODataSet. It wouldn't be strange if one of the fixes had broken
something else I figure...
p> Firstly, I used to clear parameters using:
p> Query.Params.Clear
p> In IBO4.3 this cleared the list of params, and still left the query
p> prepared.
<SNIP>
p> Anyhow that was fixed by changing Params.Clear to loop on all params
p> and call Params[i].Clear. I suspect this was just lazy coding on my
p> part and it is good that it is now fixed.
I don't think it was just lazy coding on your part. Params.Clear and
Params[i].Clear in a loop should do two different jobs: the former
should free all the TParam objects held by the TParams object, while
the latter should set all param values to Null.
I0m not sure what the prepared status of the query object should
become after calling Params.Clear, this is an area in which it is much
difficult for IBO to simulate the BDE behaviour. OTTOMH I'd say the
statement should be unprepared.
p> Then I found a new problem with boolean fields used as a parameter in
p> some SQL text. Our boolean fields are typed as a CHAR(1) field type.
p> The query is something like:
p> SELECT * FROM MYTABLE
p> WHERE (FLAGFIELD = :pFLAG)
p> And we would assign the parameter like:
p> Query.ParamByName('pFLAG').AsBoolean := True;
p> The first time the query runs everything is fine. Try
p> clearing/preparing/opening it again, and it raises an exception on
p> the Query.open routine when copying the parameter values into
p> Query.InternalDataset.
p> It appears that the parameter is valued '-1' in the
p> TIBODataSet.AssignParamValueToCol() procedure, but ACol (Internal
p> dataset column) has an .AsString value of '-' (should be '-1' but the
p> field size is only 1).
p> This causes a problem when accessing ACol as a smallint as it does
p> for ftBoolean field types.
p> I am guessing that the boolean value for true is set as (integer) -1
p> somewhere in the code. I wouldn't know where too look.
This looks like a bug indeed. I'm sure Jason could use a simple test
case if you were able to put it one together.
p> Anyhow I get around this by clearing all the
p> Query.InternalDataset.Params entries as well in a for loop.
I don't think the caual user can be expected to do that each time. :-)
Ciao
--
Nando mailto:nandod@...
p> Bare with me here - I'll try and explain it as easy as possible. This
p> is probably only of interest to Jason/Helen/et al and anyone who is
p> having troubles with parameters on IBOQuery component.
here, here. :-)
p> I upgraded from 4.1Ia to 4.3 and found some little niggly things that
p> I had to fix in our query component (extension of TIBOQuery). Things
p> may be OK now but it would be nice to let people know if they have
p> similar troubles. I don't know if its because the components have
p> been tightened up or whether they are bugs in the new IBO.
IBO 4.3 has had some bugfixing in the area of parameters and preparing
in TIBODataSet. It wouldn't be strange if one of the fixes had broken
something else I figure...
p> Firstly, I used to clear parameters using:
p> Query.Params.Clear
p> In IBO4.3 this cleared the list of params, and still left the query
p> prepared.
<SNIP>
p> Anyhow that was fixed by changing Params.Clear to loop on all params
p> and call Params[i].Clear. I suspect this was just lazy coding on my
p> part and it is good that it is now fixed.
I don't think it was just lazy coding on your part. Params.Clear and
Params[i].Clear in a loop should do two different jobs: the former
should free all the TParam objects held by the TParams object, while
the latter should set all param values to Null.
I0m not sure what the prepared status of the query object should
become after calling Params.Clear, this is an area in which it is much
difficult for IBO to simulate the BDE behaviour. OTTOMH I'd say the
statement should be unprepared.
p> Then I found a new problem with boolean fields used as a parameter in
p> some SQL text. Our boolean fields are typed as a CHAR(1) field type.
p> The query is something like:
p> SELECT * FROM MYTABLE
p> WHERE (FLAGFIELD = :pFLAG)
p> And we would assign the parameter like:
p> Query.ParamByName('pFLAG').AsBoolean := True;
p> The first time the query runs everything is fine. Try
p> clearing/preparing/opening it again, and it raises an exception on
p> the Query.open routine when copying the parameter values into
p> Query.InternalDataset.
p> It appears that the parameter is valued '-1' in the
p> TIBODataSet.AssignParamValueToCol() procedure, but ACol (Internal
p> dataset column) has an .AsString value of '-' (should be '-1' but the
p> field size is only 1).
p> This causes a problem when accessing ACol as a smallint as it does
p> for ftBoolean field types.
p> I am guessing that the boolean value for true is set as (integer) -1
p> somewhere in the code. I wouldn't know where too look.
This looks like a bug indeed. I'm sure Jason could use a simple test
case if you were able to put it one together.
p> Anyhow I get around this by clearing all the
p> Query.InternalDataset.Params entries as well in a for loop.
I don't think the caual user can be expected to do that each time. :-)
Ciao
--
Nando mailto:nandod@...