SQL/MP Programming Manual for C
Explicit Program Compilation
HP NonStop SQL/MP Programming Manual for C—429847-008
6-6
Using TACL DEFINEs in the Guardian Environment
Using TACL DEFINEs in the Guardian Environment
You can use TACL DEFINEs during the compilation of a C program containing
embedded SQL statements and directives:
To use DEFINEs, the TACL process DEFMODE attribute must be ON. To
determine the DEFMODE setting, enter the SHOW DEFMODE command at the
TACL prompt:
10> SHOW DEFMODE
Defmode OFF
If DEFMODE is OFF, enter a SET DEFMODE ON command:
11> SET DEFMODE ON
Before you run the C compiler, add the DEFINEs that you use for the names of
tables or views 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 that you use for
the names of tables, views, indexes, or collations 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 and leaves the statement
uncompiled in the program file. When you run the 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 sqlc,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. See
Running the SQL Compiler in the Guardian Environment on page 6-12 for a
description of the STOREDDEFINES option.
For information about using DEFINEs in the OSS environment, see Developing a
C Program in the OSS Environment on page 6-28.