Subject | Re: [IBO] Prepared and unprepared |
---|---|
Author | Helen Borrie |
Post date | 2003-06-30T09:55:19Z |
At 11:21 AM 30/06/2003 +0200, you wrote:
if not prepared then prepare;
isn't needed if you used ParamByName(), because this method includes that
test. Even if it didn't, both the Open() method (of bi-di datasets) and
First() method (of the uni-di dataset) also include this test.
assigning a new SQL property. Here, you are. So the above code doesn't
save you anything. Assigning a new SQL property cause the dataset to
entirely recreate itself, with all the overhead that goes with it.
Helen
> >Did you realise this is a completely unnecessary consumption ofthe statement
> >resources? If the only thing in your query that changes is the value of
> >the parameter(s) then you only have to call Refresh. The query stays both
> >active and prepared.
>
>OK - if I understand you correctly, I could accomplish the same by doing
>the following :
>
>with MyQuery do
>begin
> //Leave out the "If Active" statement
> ParamByName('XYZ').AsSomething := varXYZ;
> if not prepared then prepare; //prepare if not prepared already
> Open;
>end;
if not prepared then prepare;
isn't needed if you used ParamByName(), because this method includes that
test. Even if it didn't, both the Open() method (of bi-di datasets) and
First() method (of the uni-di dataset) also include this test.
>With queries where the SQL changes, I could do the following :No. But this wasn't what your previous example did. There, you were not
>
>with MyQuery do
>begin
> If Active then Close;
> SQL := 'some SQL string';
> ParamByName('XYZ').AsSomething := varXYZ;
> if not prepared then prepare; //prepare if not prepared already
> Open;
>end;
assigning a new SQL property. Here, you are. So the above code doesn't
save you anything. Assigning a new SQL property cause the dataset to
entirely recreate itself, with all the overhead that goes with it.
Helen