SQL/MX Programming Manual for Java
SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java—523726-003
4-8
Dynamic CONTROL Statements
Connection Context of Static CONTROL Statements
Static CONTROL statements affect only those static SQL statements with the same
connection context class because such statements are stored in the same profile.
Example
In this example, the static CONTROL QUERY DEFAULT statement does not affect
static SQL statement 2 because this statement is not associated with the same
connection context class and so is not stored in the same profile:
ctx1 = SQLMXCtx1.getDefaultContext();
#sql [ctx1] {CONTROL QUERY DEFAULT SIMILARITY_CHECK 'off'};
#sql [ctx1] { /* Static SQL statement 1 */ };
ctx1.close();
ctx2 = SQLMXCtx2.getDefaultContext();
#sql [ctx2] { /* Static SQL statement 2 */ };
ctx2.close();
Dynamic CONTROL Statements
Dynamic CONTROL statements affect only dynamic SQL statements with the same
JDBC connection in an SQLJ program.
Control Flow Scope of Dynamic CONTROL Statements
Dynamic CONTROL statements have control flow scope in an SQLJ program. That is,
a CONTROL statement affects only those dynamic statements that share the same
JDBC connection and that execute after the CONTROL statement executes in the
program.
Example
Suppose that the SQLJ program was customized with -missingSQLObject set to
true, and a few of the SQL statements referred to unavailable database objects at the
time of customization. Therefore, some SQL statements are dynamic, while others are
static in this program.
In this example, the CONTROL QUERY DEFAULT statements execute statically and
dynamically. The first CONTROL QUERY DEFAULT statement sets the catalog of the
dynamic statements to CAT1 if the department number (deptnum) is 3100 at run time.
The second CONTROL QUERY DEFAULT statement sets the catalog of the dynamic
statements to CAT2 if deptnum is not 3100 at run time. The second CONTROL
QUERY DEFAULT statement also sets the catalog of the static statements to CAT2