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-8
Invoking SPJs Statically in an Embedded SQL
Program in C, C++, or COBOL
Invoking SPJs Statically 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
statically compiled CALL statement. Place a statically compiled CALL statement within
an EXEC SQL directive:
For statically compiled CALL statements, which have static actual parameters, the
embedded program does not explicitly refer to input or output descriptors.
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.
EXEC SQL CALL procedure-name
([parameter [{, parameter}...]]);
EXEC SQL CALL procedure-name
([parameter [{, parameter}...]]) END-EXEC
C/C++
COBOL