SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual540440-003
6-34
DEFINEs
DEFINEs
A DEFINE is a named set of attribute-value pairs associated with a process. You can
use DEFINEs to pass information to a process when you start the process. DEFINEs
are often used to pass information about Guardian names. DEFINEs can be used only
for SQL/MP objects.
NonStop SQL/MX allows you to use DEFINE names as logical names for tables, views,
or partitions in SQL/MX statements that query SQL/MP objects. When NonStop
SQL/MX compiles such statements, it replaces the DEFINE name in the statement with
the Guardian name currently associated with the DEFINE.
A DEFINE name begins with an equal sign (=) followed by a letter and can contain 1 to
24 characters, including alphanumeric characters and underscores (_). Uppercase and
lowercase characters are considered equivalent in DEFINE names.
A DEFINE name must not include a reserved word. Otherwise, you cannot select data
using the DEFINE name of the table, view, or partition. See Appendix B, Reserved
Words.
The reasons for using DEFINE names in SQL/MX statements are as follows:
DEFINE names are easier to understand than Guardian names.
For example, the name =CUSTOMER is simpler than an actual file name such as
\MYSYS.$SAMDB.SALES.CUSTOMER.
DEFINE names provide location independence.
For example, if you code with DEFINE names, you can rename database objects,
move database objects, or change the database that a program accesses without
changing source code.
Using DEFINEs
DEFMODE is an attribute of a process that controls whether you can create DEFINEs
from the process and whether DEFINEs are propagated when the process starts
another process. The process can be a TACL process, an OSS shell process, an MXCI
process, or a process of your own creation. The DEFMODE attribute is ON by default
but can be set to OFF in TACL or the OSS shell.
When DEFMODE is ON, you can create, modify, delete, propagate, and display
information about DEFINEs. For example, if you start an MXCI process from a TACL
process with DEFMODE ON, DEFINEs set in the TACL process are propagated to the
MXCI process. Similarly, you can set DEFINEs in an OSS shell process and the
DEFINEs are propagated to a process you start from an OSS program with embedded
SQL statements. DEFMODE ON is the default. Note that for OSS processes,
DEFMODE ON becomes the default after the first add_define command is issued.