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

Scope of JVM Startup Options in Dynamically Compiled Applications
The UDR_JAVA_OPTIONS setting in a dynamically executed CONTROL QUERY DEFAULT statement
affects CALL statements that are dynamically prepared after the CONTROL QUERY DEFAULT
statement has executed.
For example, this CONTROL QUERY DEFAULT statement in an embedded SQL program in C sets
application-specific system properties for the SPJ environment of the dynamically prepared CALL
statement named sqlstmt1:
/* Build CALL statements in char buffers. */
strcpy(hv_sql_stmt1, "CALL samdbcat.sales.monthlyorders(?,?)");
/* IN, OUT */
strcpy(hv_sql_stmt2, "CALL samdbcat.persnl.adjustsalary(?,?,?)"
/* IN, IN, OUT */
for (i = 1; i <= 3; i++)
{
/* Set application-specific system properties for
/* the SPJ environment. */
strcpy(hv_ctrl_stmt, "CONTROL QUERY DEFAULT UDR_JAVA_OPTIONS '");
printf("\nEnter JVM startup options: ");
gets(attrval);
strcat(hv_crtl_stmt, attrval);
strcat(hv_ctrl_stmt, "'");
/* Prepare and execute the CONTROL QUERY DEFAULT statement. */
EXEC SQL EXECUTE IMMEDIATE :hv_ctrl_stmt;
/* Prepare a CALL statement. */
EXEC SQL PREPARE sqlstmt1 FROM :hv_sql_stmt1;
printf("\nEnter a number for the month: ");
scanf("%d", &hv_month_param1);
/* Call the stored procedure. */
EXEC SQL EXECUTE sqlstmt1
USING :hv_month_param1 /* IN */
INTO :hv_ordernum_param2; /* OUT */
printf("\nThe number of orders during that month is %d.\n");
/* Turn off the application-specific system properties for
/* the SPJ environment. */
strcpy(hv_ctrl_stmt, "CONTROL QUERY DEFAULT UDR_JAVA_OPTIONS 'OFF'");
}
/* Prepare another CALL statement. */
EXEC SQL PREPARE sqlstmt2 FROM :hv_sql_stmt2;
...
/* Call the stored procedure. */
EXEC SQL EXECUTE sqlstmt2
USING :hv_empnum_param1, :hv_percent_param2 /* IN, IN */
INTO :hv_newsalary_param3; /* OUT */
Dynamic CALL statements that are prepared outside of the loop, after the CONTROL QUERY
DEFAULT statement turns off the UDR_JAVA_OPTIONS setting, execute in an SPJ environment
without application-specific startup options.
For more information about the semantics of dynamic CONTROL statements in embedded SQL
programs, see the SQL/MX Programming Manual for C and COBOL or the SQL/MX Programming
Manual for Java.
38 Getting Started