Subject | RE: [IBO] Slightly surprised by IBO |
---|---|
Author | Support List |
Post date | 2011-09-14T16:53:16Z |
Set,
names in the statement being prepared that are named the same. If they are
then IBO will look at the data type to see if they are sufficiently
compatible to be treated as if they were a single input parameter. They way
you had those columns configured in your database initially did not allow
them to be treated as a single parameter. Once you made them of a compatible
definition then IBO was able to have them resolve to the same field buffer.
The SQL trace monitor will always show you all of the parameters that are
being sent to the server so it's a good idea to check there to make sure
things are working exactly as you intend.
Regards,
Jason LeRoy Wharton
> In a TIB_Query, I did something likeWhen IBO prepares your statement it looks to see if there are parameter
>
> SELECT *
> FROM OneTable
> WHERE MyField = :MyField
> UNION
> SELECT *
> FROM AnotherTable
> WHERE MyField = :MyField
>
> MyTibQuery.ParamByName('MyField').AsString:='IBO';
>
> Only results from AnotherTable appeared in the result set. Copying the
> query to IB_SQL, I discovered why - it expected two parameters! I then
> discovered that I had (erroneously) defined MyField as CHAR in OneTable,
> and as VARCHAR in AnotherTable. So I just changed the definition for one
> of the fields and everything worked as expected.
>
> Is this behaviour as intended? If so, then fine, just a small gotcha for
> me to remember whenever I try to 'reuse' a parameter. I guess that two
> different parameters with identical names also means that the first
> parameter only can be accessed through Params and not ParamByName?
names in the statement being prepared that are named the same. If they are
then IBO will look at the data type to see if they are sufficiently
compatible to be treated as if they were a single input parameter. They way
you had those columns configured in your database initially did not allow
them to be treated as a single parameter. Once you made them of a compatible
definition then IBO was able to have them resolve to the same field buffer.
The SQL trace monitor will always show you all of the parameters that are
being sent to the server so it's a good idea to check there to make sure
things are working exactly as you intend.
Regards,
Jason LeRoy Wharton