Subject | Re: [IBO] TIBOQuery modify Order affects Params |
---|---|
Author | Helen Borrie |
Post date | 2003-10-29T04:47:39Z |
On second thoughts, this procedure is pretty questionable. I think you
have more than one problem here.
Although you are not actually changing the SQL, you are forcing IBO to
invalidate your SQL by replacing the ORDER BY clause with another
(identical) ORDER BY clause. Then, you apply a whole bunch of parameters
to an unprepared query. (Params[].AsWhatever doesn't automatically prepare
an unprepared query).
If you don't need to change the ORDER BY clause, don't touch it!! That
leaves the query prepared. Changing the value of params doesn't invalidate
the SQL, as changing the ORDER BY does. Just assign the params values, and
do it *once* in the BeforeOpen event. Can't imagine why you are doing it
twice in your sample code *at all*.
NOTE If you are using Params[] instead of ParamByName to assign values,
you should *always* test the Prepared property before assigning parameters.
if not IBOQuery1.Prepared then
IBOQuery1.Prepare;
Leave OrderingItems etc. alone until you're done with your
conversion. They are IBO-only features with no equivalent in the BDE. Use
them when you're ready to look at better ways to manipulate sorts.
Helen
At 03:38 AM 29/10/2003 +0000, you wrote:
have more than one problem here.
Although you are not actually changing the SQL, you are forcing IBO to
invalidate your SQL by replacing the ORDER BY clause with another
(identical) ORDER BY clause. Then, you apply a whole bunch of parameters
to an unprepared query. (Params[].AsWhatever doesn't automatically prepare
an unprepared query).
If you don't need to change the ORDER BY clause, don't touch it!! That
leaves the query prepared. Changing the value of params doesn't invalidate
the SQL, as changing the ORDER BY does. Just assign the params values, and
do it *once* in the BeforeOpen event. Can't imagine why you are doing it
twice in your sample code *at all*.
NOTE If you are using Params[] instead of ParamByName to assign values,
you should *always* test the Prepared property before assigning parameters.
if not IBOQuery1.Prepared then
IBOQuery1.Prepare;
Leave OrderingItems etc. alone until you're done with your
conversion. They are IBO-only features with no equivalent in the BDE. Use
them when you're ready to look at better ways to manipulate sorts.
Helen
At 03:38 AM 29/10/2003 +0000, you wrote:
>with IBOQuery1 do
> begin
> close;
> Params[0].AsInteger := 0;
> Params[1].AsInteger := 999999999;
> Params[2].AsDateTime := Date;
> Params[3].AsString := '';
> Params[4].AsString := 'zzzzzzzzzzzzzzzzzzzz';
> Params[5].AsInteger := 0;
> Params[6].AsInteger := 999999999;
> Params[7].AsString := 'B';
> SQL[10] := 'ORDER BY O.ODESC ASC';
> open;
> close;
> Params[0].AsInteger := 0;
> Params[1].AsInteger := 999999999;
> Params[2].AsDateTime := Date;
> Params[3].AsString := '';
> Params[4].AsString := 'zzzzzzzzzzzzzzzzzzzz';
> Params[5].AsInteger := 0;
> Params[6].AsInteger := 999999999;
> Params[7].AsString := 'B';
> SQL[10] := 'ORDER BY O.ODESC DESC';
> open;
> end;
>The TIBOQuery SQL is set at design time as...
>
>SELECT O.ODESC, I.INVID, I.INVREVIEWED, I.INVOID, I.INVREVDAYS,
> I.INVPLANNER, I.INVSOURCE, I.INVVAR, O.ODOC FROM Invi I
> JOIN Objects O ON O.OID = I.INVOID
> WHERE I.INVSOURCE <> 'NP'
> AND I.INVPLANNER >= :FUser AND I.INVPLANNER <= :TUser
> AND (I.INVREVIEWED + I.INVREVDAYS) <= :TDate
> AND I.INVCONTROL = 'Y'
> AND I.INVID >= :FItem AND I.INVID <= :TItem
> AND O.OCLASS >= :FClass AND O.OCLASS <= :TClass
> AND O.ODESC CONTAINING :Desc
> ORDER BY O.ODESC
>
>I have played around with using the OrderingItems/OrderingItemNo
>properties instead of modifying the SQL directly but still get the
>same problem.
>
>What am I missing here?
>
>
>
>___________________________________________________________________________
>IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
>___________________________________________________________________________
>http://www.ibobjects.com - your IBO community resource for Tech Info papers,
>keyword-searchable FAQ, community code contributions and more !
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/