Subject Re: [IBO] Data Pump: More efficient way?
Author Helen Borrie
At 09:25 AM 7/09/2004 +1000, you wrote:
>In an earlier post, the following was presented as a good way of doing a
>data pump. Just wondering, what is the purpose of the "if not Prepared
>then Prepare;"?

For the dataset components, the conditional Prepare is called by
ParamByName. I always include a conditional call to Prepare for
non-dataset components. It doesn't eat anything and it avoids unexpected
GPLs from code referencing unprepared params.

>The call to parambyname should automatically do this for you.

As it does.

> The only time I call prepare is if I am going to use something
>like "params[0].AsSomeType := fields[0].AsSomeType".

Correct. But the Prepare call should be conditional.

> I used to use this for speed before upgrading to IBO 4.0... So I guess
> my question is two-fold. Is there a reason to call Prepare?

If you are referencing Params[] directly then yes. As a harmless safeguard
when calling Execute and after the SQL property is invalidated, yes (IMO).

>And is there any benefit to using the params[i] vs parambyname any more?

Certainly is. It's a much less costly method than ParamByName. And I
would continue to stress the need to call a conditional Prepare whenever
you are about to reference Params[].