SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)

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.
Invoking SPJs in a NonStop ODBC/MX Client
You can execute a CALL statement in a NonStop ODBC/MX client. Microsoft ODBC requires that
you put the CALL statement in an escape clause:
{call procedure-name ([parameter][,parameter]]...)}
For IN or INOUT parameters, use a literal or a parameter marker (?).
NOTE: You cannot use an empty string as an IN or INOUT parameter in the argument list.
If you specify a literal for an INOUT parameter, the driver discards the output value.
For OUT parameters, you can use only a parameter marker (?). You must bind all parameter
markers with the SQLBindParameter function before you can execute the CALL statement.
In this example, a CALL statement is executed from a NonStop ODBC/MX client:
/* Declare variables. */
SQLHSTMT hstmt;
SQL_NUMERIC_STRUCT salary;
SDWORD cbParam = SQL_NTS;
/* Bind the parameter markers. */
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_NUMERIC, SQL_NUMERIC,
4, 0, 202, 0, &cbParam);
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_FLOAT, SQL_FLOAT,
0, 0, 5.5, 0, &cbParam);
SQLBindParameter(hstmt, 3, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC,
8, 2, &salary, 0, &cbParam);
80 Invoking SPJs in NonStop SQL/MX