When DB2 notifies the stored procedure address space to execute a stored procedure, the thread that was created for the client application is reused for an execution. Accounting is on behalf of the client application. No sign-on or connection processing is required. Any processing done by the stored procedure is considered a logical continuation of the client application's unit of work. Thus, locks acquired by the stored procedure are released when the client application commits or rolls back.
Control is passed to the stored procedure along with the input and output parameters.
The stored procedure can issue most SQL statements. It also has access to non-DB2 resources. Before terminating, the stored procedure assigns values to the output parameters and returns control to DB2. DB2 copies the output parameters received from the stored procedure to the client application parameter area and returns control to the client application. The calling program receives the output parameters and continues the same unit of work.