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-11
Input and Output Descriptors
EXEC SQL DESCRIBE OUTPUT sqlstmt
USING SQL DESCRIPTOR 'out_sda';
For the syntax of the DESCRIBE statement, see the SQL/MX Reference Manual.
4. Set the input parameter values by using SET DESCRIPTOR.
Use the SET DESCRIPTOR statement to set information explicitly in the input SQL
descriptor area for the individual input parameters:
/* Set the input values of the two IN parameters in
* ordinal positions 1 and 2, which are the only entries
* in the input descriptor. */
printf("\nEnter the employee number: ";
scanf("%ld", &hv_empnum_param1);
hv_i = 1;
EXEC SQL SET DESCRIPTOR 'in_sda' VALUE :hv_i
VARIABLE_DATA = :hv_empnum_param1;
printf("\nEnter the percentage adjustment: ";
scanf("%f", &hv_percent_param2);
hv_i = 2;
EXEC SQL SET DESCRIPTOR 'in_sda' VALUE :hv_i
VARIABLE_DATA = :hv_percent_param2;
For the syntax of the SET DESCRIPTOR statement, see the SQL/MX Reference
Manual.
5. Execute the prepared CALL statement.
Issue an EXECUTE statement that has an input USING clause for the input SQL
descriptor area and an output INTO clause for the output SQL descriptor area:
EXEC SQL EXECUTE sqlstmt
USING SQL DESCRIPTOR 'in_sda'
INTO SQL DESCRIPTOR 'out_sda';
For the syntax of the EXECUTE statement, see the SQL/MX Reference Manual.
6. Retrieve the output parameter value by using GET DESCRIPTOR.
Use the GET DESCRIPTOR statement to retrieve information for the output
parameter from the output SQL descriptor area:
hv_i = 1;
EXEC SQL GET DESCRIPTOR 'out_sda' VALUE :hv_i
VARIABLE_DATA = :hv_newsalary_param3;
printf("\nThe new salary is %ld.\n", hv_newsalary_param3);
For the syntax of the GET DESCRIPTOR statement, see the SQL/MX Reference
Manual.
Note. You cannot modify the PARAMETER_ORDINAL_POSITION and
PARAMETER_MODE descriptor items.