Subject Re: [IBO] TIB_StoredProc management question
Author Joe Martinez
> >What would I set the SQL to?
> >Would it be "execute procedure MyProc ('12345", 234, 'Hello')"
> >Or, would it be "select retval1,retval2,retval3 from MyProc where MyParam1
> >= '12345' and MyParam2 = 234 and MyParam3 = 'Hello'"
> >or something else?
>
>If the purpose of the procedure is to return a dataset (even a one-row one)
>for work on the client, or as a provider of parameters, then you need the
>SELECT syntax. If the only purpose is to execute some DML on the server,
>then use the EXECUTE syntax. The reason is that, if you are going to have
>the user do updating, you want to keep the transaction open. Although you
>can, *don't* mix and match, or you will be exposing users to performing
>manipulation on "dirty" (uncommitted) data.

The MAIN puropse of my SP is to execute some DML, but it does return a
single value (one row, one column) that gives me the result of the
operation. I'm not using "suspend" in my SP. In this case, would it be OK
to use the EXECUTE syntax? It just seems cleaner/simpler to me.


> >Then, do I call Open() or Execute()? Which is correct in this case?
>
>Call Open on an IB_Query. Call First on an IB_Cursor. Call Execute on an
>executable (that has the EXECUTE PROCEDURE(...) syntax).

What about an IB_Cursor using the EXECUTE PROCEDURE syntax?

> >So, in my case above, I would set the SQL parameter to the correct
> >statement, prepare, and execute/select.
>
>Prepare once, then execute/select iteratively. Just test "if not Prepared
>then Prepare;" Take note that the Params[] array (a property) is not
>available in an unprepared dataset. ParamByName() and Row.ByName() are
>methods, which include this test, so you won't need it if you use either of
>them.

If I'm just calling the SP once, and putting all literals in the SQL, I
don't have to worry about the test, or explicitly preparing,
right? Setting the SQL property guarantees that the dataset is
unprepared. Calling Open(), First(), or Execute() will automatically
prepare it. Is this right?

Even when I'm doing it in a loop with parameters, I don't see why I need
the test either. If I set the SQL, I KNOW that I need to call Prepare()
once (before the loop). Then, inside the loop, I KNOW that it's been
prepared already, and it wouldn't get unprepared, right?

Thanks,
Joe