Includes an external file in an Embedded SQL source file.
exec sql include "filename" end-exec
The name of the file to be included in the Embedded SQL source file containing this statement.
The maximum supported length for the COPY statement
is 70 characters, including the file and pathname.
COPY "generic".
...
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 SRV-NAME PIC X(80).
01 UID PIC X(32).
01 PASS PIC X(32).
EXEC SQL END DECLARE SECTION END-EXEC.
...
MOVE USER-NAME TO UID.
MOVE PASSWORD TO PASS.
EXEC SQL CONNECT :UID IDENTIFIED BY :PASS END-EXEC.
EXEC SQL SELECT @@servername INTO :SRV-NAME END-EXEC.
DISPLAY "CONNECTED TO SERVER ",SRV-NAME.
Copy-file code:
01 USER-NAME PIC X(33) VALUE IS "sa".
01 PASSWORD PIC X(33) VALUE IS "syb123".
EXEC SQL INCLUDE "./generic" END-EXEC.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 SRV-NAME PIC X(80).
EXEC SQL END DECLARE SECTION END-EXEC.
EXEC SQL CONNECT :USER-NAME IDENTIFIED BY :PASSWORD END-EXEC.
EXEC SQL SELECT @@servername INTO :SRV-NAME END-EXEC.
DISPLAY "CONNECTED TO SERVER ",SRV-NAME.
Copy-file code:
01 USER-NAME PIC X(33) VALUE IS "sa".
01 PASSWORD PIC X(33) VALUE IS "syb123".
The Embedded SQL precompiler processes the included file as though it were part of the Embedded SQL source file, recognizing all declare sections and SQL statements. The Embedded SQL precompiler writes the resulting host language source code into the generated file.
Use the include path precompiler command line option to specify the directories to be searched for any included files. Refer to the Open Client/Server Programmer’s Supplement for more information on precompiler command line options.
Included files can be nested up to a maximum depth of 32 files.
The include "filename" statement can be used anywhere.
declare section