Subject Re: [IBO] Problems with TIB_Query with Parameters
Author dp075
Hello,

--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 03:48 PM 25/08/2003 +0000, you wrote:
> >Hello,
> >
> >I have two parametrized queries (TIB_Query components), one is
> >UPDATE, and the other is SELECT.
> >First one works perfectly:
> >
> >UPDATE
> > TABLE1
> >SET
> > FIELD1 = :FIELD1
> >WHERE
> > FIELD2 = :FIELD2
>
> Except TIB_Query is the wrong component for a DML query. Use
TIB_DSQL or
> IB_Cursor.

What exactly constitues incorrectness of using TIB_Query here?
What I gain using TIB_DSQL instead?
Anyways, I will try that.


> >However, the other one fails:
> >
> >SELECT
> > *
> >FROM
> > TABLE2
> >WHERE
> > (FIELD3 like :FIELD3)
>
> That's invalid SQL.

However, it worked perfectly with TIBQuery component shipped with
Delphi.

> Not just because there is no wildcard;

A wildcard is passed as a part of string parameter named 'FIELD3'.

> but, to be
> valid, a parameter has to substitute for a field value without
changing the
> structure of the query. Changing the criteria for a LIKE
expression
> changes the structure.

What is the source of this requirement? SQL stabdards, IB standards,
something else? As I said, that approached works at least in some
environments and some data access components.


> >Both queries share exactly the same properties and settings,
except
> >the SQL text shown above.
> >
> >Using equal sign instead of LIKE (my first guess) doesn't help.
> >Delphi gives an AV when trying to evaluate the value of
ParamByName
> >('FIELD3') in debug mode.
>
> Using '=' should be fine. But Params[] is nil in an unprepared
query. You
> probably tried to evaluate it too early. Set your breakpoint
*after*
> ParamByName has been called (since ParamByName calls Prepare if
the query
> isn't prepared).

OK, but query preparation _fails_.
For an (explicitely) unprepared query the attempt to assign the
value to parameters fails.

Thank you,
DP