RefLib

Reference library for AI

Back

postgresql_16:5.3.9.1 Including Files

PostgreSQL 16 > Client Interfaces > ECPG — Embedded SQL in C > Preprocessor Directives > Including Files

To include an external file into your embedded SQL program, use: EXEC SQL INCLUDE *filename*; EXEC SQL INCLUDE <*filename*>; EXEC SQL INCLUDE "*filename*"; The embedded SQL preprocessor will look for a file named *filename*.h, preprocess it, and include it in the resulting C output. Thus, embedded SQL statements in the included file are handled correctly.

The ecpg preprocessor will search a file at several directories in following order: current directory /usr/local/include PostgreSQL include directory, defined at build time (e.g., /usr/local/pgsql/include) /usr/include But when EXEC SQL INCLUDE "*filename*" is used, only the current directory is searched.

In each directory, the preprocessor will first look for the file name as given, and if not found will append .h to the file name and try again (unless the specified file name already has that suffix).

Note that EXEC SQL INCLUDE is *not* the same as: #include <*filename*.h> because this file would not be subject to SQL command preprocessing. Naturally, you can continue to use the C #include directive to include other header files.

Note

The include file name is case-sensitive, even though the rest of the EXEC SQL INCLUDE command follows the normal SQL case-sensitivity rules.

Back