Executing a Procedure
Go Up to Using Executable Procedures
To execute a procedure in an application, use the following syntax:
EXEC SQL EXECUTE PROCEDURE name [:param [[INDICATOR]:indicator]] [, :param [[INDICATOR]:indicator] ...] [RETURNING_VALUES :param [[INDICATOR]:indicator] [, :param [[INDICATOR]:indicator]...]];
When an executable procedure uses input parameters, the parameters can be literal values (such as 7 or “Fred”), or host variables. If a procedure returns output parameters, host variables must be supplied in the RETURNING_VALUES
clause to hold the values returned.
For example, the following statement demonstrates how the executable procedure, DEPT_BUDGET
, is called with literal parameters:
EXEC SQL EXECUTE PROCEDURE DEPT_BUDGET 100 RETURNING_VALUES :sumb;
The following statement also calls the same procedure using a host variable instead of a literal as the input parameter:
EXEC SQL EXECUTE PROCEDURE DEPT_BUDGET :rdno RETURNING_VALUES :sumb;