SQL/MX Programming Manual for Java
SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java—523726-003
4-38
Using SQL/MP Alias Statements in an SQLJ
Program
Using SQL/MP Alias Statements in an SQLJ Program
The CREATE SQLMP ALIAS statement enables you to use logical names (for
example, cat.sch.tab) for SQL/MP tables or views by mapping an SQL/MP alias to
a Guardian physical file. The ALTER SQLMP ALIAS and DROP SQLMP ALIAS
statements enable you to change the table mapping or drop the alias, respectively.
Embedding a CREATE SQLMP ALIAS Statement
If you embed a CREATE SQLMP ALIAS statement in an SQLJ program, subsequent
references to the SQL/MP alias in the same program cause customization problems by
default and cause the SQL statements that use these aliases to run dynamically. For
more information, see Missing or Unavailable Database Objects on page 4-2.
To prevent unpredictable results, execute CREATE SQLMP ALIAS statements from
MXCI or a separate embedded program before compiling an SQLJ program that uses
those aliases.
Embedding an ALTER SQLMP ALIAS Statement
An embedded ALTER SQLMP ALIAS statement in an SQLJ program does not affect
references to the alias in the same program during customization. At run time, the
ALTER SQLMP ALIAS statement changes the mapping of the alias in the metadata.
Statically compiled statements that use the alias are not affected by this change.
However, dynamically run statements, or statically compiled statements that undergo
automatic recompilation, are affected by the change and use the newly assigned table.
To prevent unpredictable results, execute ALTER SQLMP ALIAS statements from
MXCI or a separate embedded program before compiling an SQLJ program that uses
those aliases.
Embedding a DROP SQLMP ALIAS Statement
An embedded DROP SQLMP ALIAS statement in an SQLJ program does not affect
references to the alias in the same program during customization. At run time, the
DROP SQLMP ALIAS statement removes the alias from the metadata. Statically
compiled statements that use the alias are not affected by the removal of the alias.
However, dynamically run statements, or statically compiled statements that undergo
automatic recompilation, are affected by the removal of the alias and fail at run time
because the alias no longer exists.
To prevent unpredictable results, verify that SQLJ programs do not use the alias before
you remove it by using the DROP SQLMP ALIAS statement.
For more information about using SQL/MP aliases, see SQL/MP Aliases for SQL/MP
Objects on page 4-21.