SQL/MX Programming Manual for Java

SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java523726-003
4-23
Compile-Time Name Resolution for SQL/MP Objects
For more information about the SQLJ command-line options, see SQLJ Translator
Command Line on page 5-10. For more information about the SYSTEM_DEFAULTS
table, see the SQL/MX Reference Manual.
Compile-Time Name Resolution for SQL/MP Objects
Compile-time name resolution is an SQL/MX extension you use to customize and
compile a module with statements that refer to SQL/MP tables or views with class MAP
DEFINEs. For each statement, the SQL/MX compiler prepares a plan that is specific
to, and optimized for, the physical table referenced in the file attribute of the DEFINE at
the time of customization.
By using compile-time resolution, you can also reinitialize the DEFINEs to values that
differ from those used when the profile was first customized, and then recustomize the
profile and recompile the module to prepare plans for a different set of tables than the
application was originally built to process, without changing the source code of the
application.
To use compile-time name resolution to prepare two or more applications from the
same source module, where each application processes its own set of tables, consider
using the targeting technique of module management. See Targeting on page 6-15. If
you do not use this technique, the compiled module file of the second application
overwrites the module file of the first application.
Late Name Resolution for SQL/MP Objects
Late or run-time name resolution is an SQL/MX extension that enables an embedded
SQL program to use class MAP DEFINEs in place of SQL/MP table names in DML
statements. During explicit SQL compilation, the SQL/MX compiler uses the tables
from the DEFINEs to generate a query execution plan for each DML statement. At run
time, you can control which table the statement processes by changing the table name
in the value of a DEFINE. You can specify the same table for which the statement was
originally customized, or you can specify a different table.
Each time a DML statement executes, the SQL/MX executor compares the name of
the table for which the plan was compiled against the name taken from the run-time
DEFINE. If the run-time DEFINE does not exist, the SQL/MX executor uses the
compile-time DEFINE specified in the module. For an SQLJ iterator, the SQL/MX
executor resolves the tables names when the iterator is initialized. If the compile-time
and run-time names do not match, the SQL/MX executor performs a similarity check of
the tables to determine if the query execution plan of the DML statement is still
operable. If the similarity check fails (or is disabled), the SQL/MX executor, by default,
invokes the SQL/MX compiler to automatically recompile the SQL plan.
Use late name resolution to move applications (that is, Java class files and modules)
from a development system to a production system without having to recustomize the
DML statements on the production system. To use late name resolution in this way, the
tables on the production system must be structurally similar to the tables on the
development system. In other words, the tables on the production system must pass