Subject Re: [IBO] Re: Correct Way to Use TIB_StoredProc
Author Helen Borrie
At 09:32 PM 19/04/2003 +0000, you wrote:
> >it's actually more efficient to use TIB_DSQL and TIB_Query for
>executable and selectable stored procedures, respectively
>
>I am playing with a remote Linux server accessed via a slow TCP/IP
>connection.
>
>The first thing I noted was how slow is the Prepare method of a
>TIB_StoredProc.
>
>Now I understand that I should use a TIB_DSQL.
>
>Ok.
>
> > With any of the components, the Params[] array gets cleared
>whenever the component is unprepared. Unprepare occurs whenever you
>change the SQL property or, in the case of TIB_StoredProc, the
>StoredProcName.
>
>What if I want to use the same SP with new parameters ?

No, this does not change the structure of the SQL and so a prepare is not
necessary (and should not be allowed by your code, if you care about
performance!)


>The following code works:
>
>Prepare;
>ParamByName('parm1').Value:=SameValue1;
>ParamByName('parm2').Value:=SameValue2;
>ExecSQL;
>
>But it is rather slow.
>
>Is there any faster way to feed new parameters to a SP ?

Yes. Keep it prepared. Your code should be:

if not Prepared then Prepare; <-- only needs to be done once
ParamByName('parm1').Value:=SameValue1;
ParamByName('parm2').Value:=SameValue2;
ExecSQL;

For batches, you will also make it faster if you place batches of up to
2000 calls to the procedure inside a single, explicit transaction.

Helen