EXECSP

Executes a stored procedure.

Syntax:

>>--EXEC SQL-.----------------.-EXECSP-.---------------.->
             +-FOR :host_integer-+        +-:result_hvar -+

 >-- stored_procedure_name -----.------------.------------->
                                | +-- , --+  |
                                | V       |  |
                                +(parameter)-+

 >-.----------------.------------------------END-EXEC-----<>
   +-WITH RECOMPILE-+

Parameters:

:host_integer A host variable that specifies the maximum number of host array elements processed. Must be declared as PIC S9(4) COMP-5 or PIC S9(9) COMP-5.
:result_hvar A host variable to receive the procedure result.
stored_procedure_name The name of the stored procedure.
parameter A literal or a host variable parameter of the form:
[keyword=]:param_hvar [OUT | OUTPUT]

where:

keyword is the formal parameter name for a keyword parameter.
:param_hvar is a host variable.
OUT specifies an output parameter.
OUTPUT specifies an output parameter.
WITH RECOMPILE Is ignored and has no effect. It is allowed for syntax compatibility only.

Comments:

The EXECSP statement is an alternative to the CALL statement and provides backward compatibility with the Micro Focus Embedded SQL Toolkit for Microsoft SQL Server. Wherever possible, the CALL statement should be used in preference to EXECSP.

Do not use the FOR clause if the EXECSP is part of a DECLARE CURSOR statement.

Example:

EXEC SQL
   EXECSP myProc param1,param2
END-EXEC

EXEC SQL
   EXECSP :myResult = myFunction namedParam = :paramValue
END-EXEC

EXEC SQL
   EXECSP getDept :empName, :deptName OUT
END-EXEC

EXEC SQL
   DECLARE cities CURSOR FOR EXECSP locateStores :userState
END-EXEC