Subject Re: [IBO] Stored procedure, ExecSQL and Suspend
Author Helen Borrie
At 04:01 PM 02-11-02 +0000, you wrote:


> IF ((OUT_DIFFERENZIA='E') OR (OUT_DIFFERENZIA IS NULL)) THEN
> OUT_DIFFERENZIA='N';
> SUSPEND; /* ****************************** */
>END
>
>Needs the final suspend...
>
>The question is:
>What component must I use in IBO for retrieving output values from this
>kind of SP? What method do I have to call (i.e. ExecSQL, Open...)?

The SUSPEND won't make any difference on the server side. It *only* takes
effect at the end of a For...Select..Do loop. In all other cases, it means
the same thing as EXIT.

The server always returns the values in the return parameter block
following the COMMIT, and IBO reads them in from there. You should read
them as Fields[], not Params[]. IBO reserves Params[] for input parameters.


>Jason once told about ExecSQL "That method is what you call to execute a
>non-select SQL statement",

In fact, ExecSQL is there just for compatibility with the VCL. Execute()
is the native IBO method.

>is this EXECUTE PROCEDURE GET_CONTO_DIFFERENZIA_GR in my
>IB_StoredProcedure to be considered a "select" statement?

No, it is an execute statement and is correct for a SP that does not return
a dataset.

>What is the general rule?

Use SELECT for a SP that you have defined to return a dataset. This style
of SP is distinguished by a FOR...SELECT....DO...SUSPEND loop, each
iteration of which outputs a single row of a dataset.

Use EXECUTE for a SP that performs *anything* except a FOR..SELECT..etc.

Don't design SELECTable SPs that modify data (yes, the engine will let you
do it but commonsense and ACID rules say "No").

Read output parameters from the Fields[] array AFTER the executable
procedure's work has been committed.

Helen