SQL/MX Programming Manual for Java

SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java523726-003
4-7
Static CONTROL Statements
If you set -missingSQLObject to true during customization, the CONTROL
statements are applied statically and also execute dynamically at run time by calling
JDBC. When the CONTROL statements execute dynamically, they affect other
dynamic SQL statements within their control flow scope and JDBC connection.
You might not always know when an embedded SQL statement in an SQLJ program
executes dynamically. Therefore, you should be familiar with the differences in
influence and scope of static and dynamic CONTROL statements and code the
CONTROL statements to anticipate possible dynamic behavior.
Static CONTROL Statements
Static CONTROL statements affect only static SQL statements with the same
connection context in an SQLJ program.
Line Order Scope of Static CONTROL Statements
Static statements follow line order scope. That is, the scope of a static CONTROL
statement is based on the order of the SQL statements in the SQLJ program. A
CONTROL statement affects only those static SQL statements with the same
connection context that appear immediately after the CONTROL statement in the
program, and the CONTROL statement stays in effect until it is replaced by another
CONTROL statement with the same connection context.
Example
Suppose that an SQLJ program was successfully customized with
-missingSQLObject set to false. In this example, the first static CONTROL QUERY
DEFAULT statement turns off the similarity check for static SQL statements 1 to 3. The
second CONTROL QUERY DEFAULT statement turns on the similarity check for static
SQL statements 4 to 6. Note that these CONTROL statements affect only the static
SQL statements with the same ctx connection context:
try {
#sql [ctx] {CONTROL QUERY DEFAULT SIMILARITY_CHECK 'off'};
#sql [ctx] { /* Static SQL statement 1 */ };
#sql [ctx] { /* Static SQL statement 2 */ };
#sql [ctx] { /* Static SQL statement 3 */ };
#sql [ctx] {CONTROL QUERY DEFAULT SIMILARITY_CHECK 'on'};
#sql [ctx] { /* Static SQL statement 4 */ };
#sql [ctx] { /* Static SQL statement 5 */ };
#sql [ctx] { /* Static SQL statement 6 */ };
}