CALL statement

The CALL statement can be used to invoke other stored procedures. At maximum 64 levels of routines can be nested (e.g. ProcA is calling ProcB – ProcB is calling ProcC – etc.). Furthermore recursive calls are supported. You’ve just to close all open cursors before making the recursive call.

If you’re calling a stored procedure with the CALL statement all input, output and inout parameters must be specified. DB2 does not support default values. For output parameters you’ve to use the question mark in the statement.

Example:

 CALL myproc ( <inputvalue1>, <inputvalue2>, ?, ? );

Calling stored prodedures which are written in other languages is also supported.

As well it’s possible to call a stored procedure from your application: Calling a stored procedure from your application

If you want to return a whole result set of a called stored procedure, you’ve to use the ALLOCATE CURSOR and the ASSOCIATE LOCATOR statements in your code.

 


Link to the DB2 Information Center: DB2 9.7 DB2 10.1 DB2 10.5