SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Embedded SQL Statements
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
2-13
ANSI Compliance and Portability
•
CONTROL QUERY SHAPE, which forces execution plans by modifying the 
operator tree for a prepared statement
•
CONTROL TABLE, which specifies a performance-related option for DML 
accesses to a table or view
For the syntax of CONTROL statements, see the SQL/MX Reference Manual.
ANSI Compliance and Portability
If program portability is important, note that CONTROL statements are SQL/MX 
extensions to the ANSI standard.
Static and Dynamic CONTROL Statements
CONTROL statement directives influence static SQL statements and dynamic SQL 
statements differently. As a programmer, you need to be aware of these differences to 
minimize confusion regarding the scope and influence of CONTROL statements in 
your program.
CONTROL, Line Order Scope, and Static SQL programs
In an embedded static SQL program, CONTROL statements are preceded by the 
preprocessor EXEC SQL directive. In this type of program, a CONTROL statement 
directive applies only to static SQL statements. Moreover, CONTROL statements apply 
to all statements that follow the CONTROL statement until superseded by another 
EXEC SQL CONTROL statement. This type of scope is commonly referred to as line 
order scope and applies exclusively to static SQL statements.
CONTROL, Flow Control Scope, and Dynamic SQL programs
In a dynamic SQL program, CONTROL statements are executed dynamically. In 
MXCI, for example, you enter CONTROL statements in the same manner as other 
SQL statements. You can execute CONTROL statements in a C or COBOL program 
with either PREPARE/EXECUTE or EXECUTE IMMEDIATE. In this type of a program, 
the scope is such that dynamically executed CONTROL statements apply only to 
dynamic SQL statements that are executed after the CONTROL statement has been 
executed. This type of scope is called flow control scope and applies exclusively to 
dynamic SQL statements. Example 2-1 on page 2-14 illustrates the different types of 
Note. Scoping rules behave differently for NonStop SQL/MP than for NonStop SQL/MX. Static 
statements are in pure listing order in NonStop SQL/MX. The scope is reset at each procedure 
boundary in NonStop SQL/MP. For more information about the differences between NonStop 
SQL/MP and NonStop SQL/MX, see the SQL/MX Comparison Guide for SQL/MP Users.










