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 COBOL523627-004
8-4
Table and View Name References
PROTOTYPE Host Variables For SQL/MP and SQL/MX
Objects
When you use a PROTOTYPE host variable to refer to a table or view, the SQL
statement is compiled using the definition of the table or view specified in the
PROTOTYPE clause. At run time, the plan is executed using the table or view name
that you pass to the host variable. Because PROTOTYPE host variables refer
dynamically to tables or views, they enable late name resolution. For more information,
see Late Name Resolution on page 8-6.
To specify a PROTOTYPE host variable in place of a table name in an embedded DML
statement, use this syntax:
:hostvar
is a host variable that contains the SQL table name at run time. It can be any valid
host language identifier with a data type that corresponds to an SQL data type. You
must precede hostvar with a colon (:) within an SQL statement.
The table name in hostvar can be either:
Three-part logical name for accessing SQL/MP tables (if using MPALIAS) or
SQL/MX tables
Four-part Guardian file name for accessing SQL/MP tables
You must use the same form for both the PROTOTYPE and hostvar value. For
example, if the value specified in the PROTOTYPE clause is a Guardian file name,
the actual name passed in through hostvar must also be a Guardian name.
You must initialize hostvar with a table name before the statement executes. If a
three-part logical name is not fully qualified, NonStop SQL/MX uses default catalog
and schema values as described in the SQL/MX Reference Manual.
PROTOTYPE { '[[catalog.]schema.]table' }
{ '[\system.][[$volume.]subvolume.]table' }
is one of these name types enclosed in single quotation marks ('):
Three-part logical name of an SQL/MP alias or SQL/MX table of the form
catalog.schema.table
Four-part Guardian name of an SQL/MP table of the form
\system.$volume.subvolume.table
Note. Before using PROTOTYPE host variables in OLTP applications, see OLT Optimization
Considerations for DEFINE Names and PROTOTYPE Host Variables on page 8-5.
:hostvar PROTOTYPE {'[[catalog.]schema.]table' }
{'[\system.][[$volume.]subvolume.]table' }