SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)
In this example of an embedded SQL program in C, the static CALL statement has an IN parameter
argument consisting of a host variable, an IN parameter argument of 5.5, and an OUT parameter
argument consisting of another host variable:
EXEC SQL BEGIN DECLARE SECTION;
NUMERIC(4) hv_empnum_param1;
double hv_percent_param2;
NUMERIC(8,2) hv_newsalary_param3;
EXEC SQL END DECLARE SECTION;
/* Set the IN arguments. */
hv_empnum_param1 = 202;
hv_percent_param2 = 5.5;
/* Call the stored procedure.
* Parameter modes are IN, IN, OUT */
EXEC SQL CALL samdbcat.persnl.adjustsalary(:hv_empnum_param1,
:hv_percent_param2,,
:hv_newsalary_param3);
/* Print the OUT parameter value. */
printf("\nThe new salary is %ld.\n", hv_newsalary_param3);
For information about writing embedded SQL programs in C, C++, or COBOL, see the SQL/MX
Programming Manual for C and 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 (page 77)
• Argument Lists (page 79)
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).
Invoking SPJs Dynamically in an Embedded SQL Program in C, C++, or COBOL 77










