The include directive
The include directive allows you to specify a file to include within your program.
The preprocessor places the contents of the specified file into the source file. Stage 1 of the preprocessor reads the contents of filename into the current file at the position of the include directive.
- EXEC SQL include filename;
- $include filename;
Replace filename with the name of the file you want to include in your program. You can specify filename with or without quotation marks. If you use a full path name, however, you must enclose the path name in quotation marks.
EXEC SQL include decimal.h;
EXEC SQL include "C:\apps\finances\credits.h";
If you omit the quotation marks around the file name, changes the file name to lowercase characters. If you omit the path name, the preprocessor checks the preprocessor search path for the file. For more information about this search path, see Name the location of include files.
- The header
file You do not have to use the .h file extension for the header file; the compiler assumes that your program refers to a file with a .h extension. The following examples show valid statements to include header files:
EXEC SQL include varchar.h; $include sqlda; EXEC SQL include sqlstype;
- Other user-defined files
You must specify the exact name of the file that you want to include. The compiler does not assume the .h extension when you include a header file that is not the header file.
The following examples show valid statements to include the files constant_defs and typedefs.h in a UNIX™ environment:EXEC SQL include constant_defs; EXEC SQL include "constant_defs"; $include typedefs.h; EXEC SQL include "typedefs.h";
You must use the include directive if the file you specify contains embedded SQL statements, or other statements.