SQL/MP Programming Manual for COBOL85

Explicit Program Compilation
HP NonStop SQL/MP Programming Manual for COBOL85429326-004
6-5
Using DEFINEs in the Guardian Environment
Using DEFINEs in the Guardian Environment
You can use DEFINE names in an SQL program to specify the names of SQL catalogs
and objects (tables, views, indexes, partitions, and collations). You must set all
DEFINE names used in SQL statements before SQL load time (the time when an SQL
program executes its first statement) unless your program uses execution-time name
resolution. Use a class CATALOG DEFINE for a catalog and a class MAP DEFINE for
an object, as follows:
To use DEFINEs, the DEFMODE attribute must be ON for your TACL process. To
determine the DEFMODE setting, enter the SHOW DEFMODE command at the
TACL prompt:
10> SHOW DEFMODE
Defmode OFF
If DEMODE is OFF, enter a SET DEFMODE ON command:
11> SET DEFMODE ON
Before you run the compiler, add the DEFINEs for any names of SQL objects you
use in INVOKE directives.
12> ADD DEFINE =employee, CLASS MAP, FILE persnl.employee
13> ADD DEFINE =emplist, CLASS MAP, FILE persnl.emplist
...
Before you run the SQL compiler (SQLCOMP), add the DEFINEs for the names of
tables, view, indexes, or collations you use in SQL statements.
20> ADD DEFINE =dept, CLASS MAP, FILE persnl.dept
21> ADD DEFINE =xempname, CLASS MAP, FILE persnl.xempname
22> ADD DEFINE =collate1, CLASS MAP, FILE collate1
...
If you specify a DEFINE name in an SQL statement that is not in your current set
of DEFINEs, the SQL compiler issues a warning message and leaves the
statement uncompiled in the object file. When you run your program, the SQL
executor automatically tries to recompile the SQL statement. If the DEFINE is still
not available at run time, the SQL compiler issues an error message.
When you run the SQL compiler, you can specify a CLASS SPOOL DEFINE for
the OUT file and a class CATALOG DEFINE for the catalog option. If you use these
DEFINEs, add them before you enter the SQLCOMP command:
30> ADD DEFINE =persnl, CLASS CATALOG, SUBVOL persnl
31> ADD DEFINE =sqlist, CLASS SPOOL, LOC $S.#sqlist
32> SQLCOMP /IN sqlcbprg,OUT =sqlist,NOWAIT/ CATALOG =persnl
To use the DEFINEs stored in the program file when you explicitly recompile a
program, specify the STOREDDEFINES option of the SQLCOMP command. For a
Note. For information on adding DEFINEs in an OSS environment, see Using DEFINEs in
the OSS Environment on page 6-6.