SQL/MP Programming Manual for COBOL

Program Invalidation and Automatic SQL
Recompilation
HP NonStop SQL/MP Programming Manual for COBOL529758-003
8-9
Run-Time Recompilation Errors
Run-Time Recompilation Errors
If an automatic SQL recompilation is successful, the SQL statement executes.
However, if the recompilation fails, the SQL executor returns compilation errors or
warnings:
Recompilation of a single statement. The SQL executor returns error information to
the SQLCODE variable and the SQLCA structure (if declared).
Recompilation of an entire program. If an entire program is recompiled, an SQL
statement that causes an error or warning remains uncompiled and the SQL
executor suppresses the error or warning message. If the SQL executor
subsequently executes the uncompiled statement, the SQL executor tries again to
recompile the statement. If the statement still causes a compilation error or
warning, the SQL executor returns error information to the SQLCODE variable and
the SQLCA structure (if declared).
Preventing Automatic Recompilations
The SQL executor can perform the similarity check for SQL objects to determine if an
invalid execution plan is operable or inoperable. An operable plan is semantically
correct and can execute correctly without SQL recompilation (although the plan might
not be optimal), whereas an inoperable plan must be recompiled to execute correctly.
By performing the similarity check, the SQL executor recompiles only SQL statements
that have inoperable execution plans. It executes other SQL statements by using their
existing plans. Executing the similarity check for an SQL statement eliminates
unnecessary recompilations and is much faster than recompiling the statement.
This subsection describes the CHECK option and its effect on the SQL executor at run
time. The COMPILE option directs the SQL compiler to perform similarity checks
during explicit SQL compilation to explicitly recompile only statements with inoperable
plans. For more information about the CHECK and COMPILE options, including their
syntax, see Section 6, Explicit Program Compilation
.
To direct the SQL executor to perform similarity checks for a program at run time,
follow these steps:
1. Explicitly compile the program by using the CHECK INOPERABLE PLANS option.
2. Enable the similarity check by using DDL statements for each table or protection
view referenced in the program. (SQL/MP implicitly enables the similarity check for
other SQL objects.)
Note. You cannot use the similarity check for a query that uses parallel execution plans.
At run time, a query that uses parallel execution plans will fail the similarity check, and the
SQL statement containing the query must be automatically recompiled before it can
execute (if NORECOMPILE is not specified). To use the similarity check in this query, you
must disable parallel execution by using a CONTROL QUERY PARALLEL EXECUTION
OFF directive.