SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

Invoking SPJs in NonStop SQL/MX
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
5-9
Invoking SPJs Dynamically in an Embedded SQL
Program in C, C++, or COBOL
Invoking SPJs Dynamically in an Embedded
SQL Program in C, C++, or COBOL
In an embedded SQL program in C, C++, or COBOL, you can invoke an SPJ in a
dynamically executed CALL statement. For dynamic CALL statements, supply dynamic
input data either through an SQL descriptor area or by using host variables. Similarly,
you can place dynamic output data either into an SQL descriptor area or directly into
host variables. For more information, see:
Input and Output Descriptors on page 5-9
Argument Lists on page 5-12
Input and Output Descriptors
You can use SQL descriptor areas to store and retrieve information about the input and
output parameters of a dynamic CALL statement.
Formal and Actual Parameters
A formal parameter is one of the parameters in the formal procedure signature of a
CREATE PROCEDURE statement, and an actual parameter is one of the parameter
arguments in the procedure call of a CALL statement. More than one actual parameter
can map to one formal parameter, so the number of actual parameters might be more
than the number of formal parameters.
Suppose that an SPJ is defined to accept three parameter arguments with
PARAMETER_MODE IN, OUT, and IN in this order:
CALL myproc(?w /*IN*/, ?x /*OUT*/, ?y + ?z /*IN*/);
This CALL statement has three formal parameters (w, x, and y+z) and four actual
parameters (w, x, y, and z). The PARAMETER_ORDINAL_POSITION of the
parameters is (1, 2, 3, 3).
Suppose that this CALL statement uses a duplicate actual parameter:
CALL myproc(?w /*IN*/, ?x /*OUT*/, ?w + ?y /*IN*/);
In this case, there are three actual parameters (w, x, and y). The
PARAMETER_ORDINAL_POSITION of the parameters is (1, 2, 3).
Number of Entries in Input and Output Descriptors
In dynamic SQL, the input descriptor has n entries, where n is the number of actual
parameters that map to formal IN and INOUT parameters. n is not necessarily the
same as the number of formal IN and INOUT parameters.
Conversely, the output descriptor has m entries, where m is the number of actual
parameters that map to formal OUT and INOUT parameters. m is the same as the