Application Development

ODBCLink/SE Reference Manual

Using Stored Procedures

ODBCLink/SE implements all types of ALLBASE/SQL stored procedures, including those which return multiple- format results sets. You can list the stored procedures available to your ODBC session by calling SQLProcedures and you can get parameter information for stored procedures by calling SQLProcedureColumns.

Stored procedures return data either through bound parameters or through one or more results sets. To get a return value that is a procedure parameter, prepare an SQL statement (with SQLPrepare) of the form:

{?=call owner.procedue (?,?..)}

Then bind the parameters with SQLBindParameter, specifying an output parameter where appropriate (SQLProcedureColumn will tell you which are input, which are output, and which are input/output parameters). Then call SQLExecute. The return value(s) will be copied to the storage locations that you specify. Note that all stored procedures return an integer return status called RETURN_STATUS.

If your stored procedure also returns one or more result sets, you call SQLNumResultCols, SQLDescribeCol, SQLFetch, SQLGetData in the normal way you would for any Select statement. If the procedure returns more than 1 result set, you call SQLMoreResults when you get to the end of the first result set, and, if successful, you can then retrieve another result set. It is permissible to call SQLMoreResults() at any time to switch to a different result set.

 

ODBCLink/SE

28

©M.B. Foster Associates Limited 1995-2000

Page 38
Image 38
HP MPE/iX 6.x Operating System manual Using Stored Procedures, ?=call owner.procedue ?,?