SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Name Resolution, Similarity Checks, and Automatic 
Recompilation
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
8-12
Automatic Recompilation
Automatic Recompilation 
Automatic recompilation is the run-time recompilation, invoked by the SQL/MX 
executor, of a DML statement in a module. During automatic recompilation, the SQL 
plan changes but is not written to the module. Instead, it is stored in the memory of the 
SQL/MX executor.
Automatic recompilation incurs a performance cost because it requires the query 
execution plan to be regenerated at run time and stored in memory. Automatically 
recompiled query plans are not saved for subsequent executions of the same program 
or for multiple concurrent executions of the same program. Because of this limitation, 
automatic recompilation might be unsuitable for some production environments.
Causes of Automatic Recompilation
By default, automatic recompilation is enabled for all embedded SQL programs. 
Automatic recompilation occurs if:
•
The value of a class MAP DEFINE or PROTOTYPE host variable changes or the 
timestamp of a table changes, and the similarity check fails or is disabled. For 
more information, see Similarity Check on page 8-8.
•
A DML statement was not compiled when you explicitly SQL compiled the module 
definition because the table did not exist or was unavailable at that time. For more 
information, see Running the SQL/MX Compiler on page 15-26.
•
A transaction mode changes because of a SET TRANSACTION statement. For 
more information, see Setting Attributes for Transactions on page 14-3.
Controlling Automatic Recompilation
By default, automatic recompilation is enabled for all embedded SQL programs. To 
disable automatic recompilation at run time and force the explicit recompilation of DML 
statements, use the CONTROL QUERY DEFAULT statement with the 
AUTOMATIC_RECOMPILATION option set to OFF:
CONTROL QUERY DEFAULT AUTOMATIC_RECOMPILATION 'OFF';
Automatic recompilation remains OFF until the end of the embedded SQL program or 
until the occurrence of a CONTROL QUERY DEFAULT statement with 
AUTOMATIC_RECOMPILATION set to ON.
Controlling Automatic Recompilation Messages
By default, to comply with the ANSI standard, the SQL/MX executor does not return a 
warning message to the program when a DML statement is automatically recompiled. 
NonStop SQL/MX always logs a warning event, SQL/MX message 505, to the Event 
Management Service (EMS) log when a statement is automatically recompiled. For 
more information, see the EMS Manual and Operator Messages Manual. 










