Restriction: This topic applies to Windows environments only.
A typical stored procedure contains two or more SQL statements, and some manipulative or logical processing that you cannot include in an SQL statement. In this example, your application, CALLSTPR, runs on a workstation client and calls a stored procedure, STPROC1. The following process occurs:
- The workstation application establishes a connection to the XDB Server.
- The SQL statement CALL tells the XDB Server that the application is going to run the stored procedure, STPROC1. The calling application provides the necessary parameters.
- The XDB Server searches the catalog table SYSIBM. SYSROUTINES for rows associated with stored procedure STPROC1.
- The XDB Server passes information about the request to the stored procedure.
- The stored procedure executes SQL statements.
- The stored procedure assigns values to the output parameters and then exits.
- Control returns to the calling application, which receives the output parameters. The XDB Server:
- Closes all cursors that the stored procedure opened that weren't defined as WITH RETURN. Cursors that were defined as WITH RETURN are closed by the XDB Server when a COMMIT WORK command is issued if the WITH HOLD attribute was not declared on the stored procedure generated cursor.
- Discards all SQL statements that the stored procedure prepared.
- Reclaims the working storage that the stored procedure used.
The application can call more stored procedures or it can execute more SQL statements.
- Once control is returned to the program that invoked the stored procedure, the XDB Server will treat all the work generated by the stored procedure (and subsequently by the calling program) as a single transaction.