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-12
Argument Lists
7. Retrieve parameter descriptor information by using GET DESCRIPTOR.
Aside from obtaining data about the output dynamic parameters, you can also use
the GET DESCRIPTOR statement to retrieve the PARAMETER_MODE and
PARAMETER_ORDINAL_POSITION descriptor items for dynamic parameters.
In this example, the GET DESCRIPTOR statement stores the
PARAMETER_MODE and PARAMETER_ORDINAL_POSITION information in
designated host variables for the OUT parameter:
hv_i = 1;
EXEC SQL GET DESCRIPTOR 'out_sda' VALUE :hv_i
VARIABLE_DATA = :hv_newsalary_param3
PARAMETER_MODE = :pm_newsalary_param3
PARAMETER_ORDINAL_POSITION = :pop_newsalary_param3;
For more information about descriptor items, see the SQL/MX Reference Manual.
For more information about writing embedded SQL programs in C, C++, or COBOL,
see the SQL/MX Programming Manual for C and COBOL.
Argument Lists
You can execute an embedded dynamic CALL statement without input or output
descriptors. Instead, pass two argument lists in the input USING clause and the output
INTO clause directly to the EXECUTE statement.
In this example, an embedded dynamic CALL statement uses argument lists:
EXEC SQL BEGIN DECLARE SECTION;
NUMERIC(4) hv_empnum_param1;
double hv_percent_param2;
NUMERIC(8,2) hv_newsalary_param3;
CHAR hv_sql_stmt[64];
EXEC SQL END DECLARE SECTION;
/* Build the CALL statement in a char buffer. */
strcpy(hv_sql_stmt, "CALL samdbcat.persnl.adjustsalary(?,?,?)");
/* IN, IN, OUT */
/* Prepare the statement. */
EXEC SQL PREPARE sqlstmt FROM :hv_sql_stmt;
/* Set the input values of the two IN parameters in
* ordinal positions 1 and 2.
printf("\nEnter the employee number: ";
scanf("%ld", &hv_empnum_param1);
printf("\nEnter the percentage adjustment: ";
scanf("%f", &hv_percent_param2);
/* Call the stored procedure. */
EXEC SQL EXECUTE sqlstmt
USING :hv_empnum_param1, :hv_percent_param2 /* IN, IN */
INTO :hv_newsalary_param3; /* OUT */
printf("\nThe new salary is %ld.\n", hv_newsalary_param3);
For more information about writing embedded SQL programs in C, C++, or COBOL,
see the SQL/MX Programming Manual for C and COBOL.