include "filename"

Description

Includes an external file in an Embedded SQL source file.

Syntax

exec sql include "filename"; 

Parameters

filename

The name of the file to be included in the Embedded SQL source file containing this statement.

Examples

Example 1

common.h:
    /* This file contains definitions and
     ** declarations used in the file getinfo.c. 
     */
 
 #include <stdio.h>
 #include “./common.h”
 void    err_handler();
 void    warning_handler();
 exec sql include sqlca;
 {
    exec sql begin declare section;
              CS_CHAR username[33], password[33], date[33];
    exec sql end declare section;
 
    exec sql whenever sqlerror call err_handler();
    exec sql whenever sqlwarning call warning_handler();
    exec sql whenever not found continue;
 
 /*
 ** Copy the user name and password defined in common.h to
 ** the variables decalred for them in the declare section.
 */
 strcpy (username, USER);
 strcpy(password, PASSWORD);
 
 printf(“Today’s date: %s\n”, date);
 ...
 }
 void     err_handler()
 {
 ...
 }
 void     warning_handler()
 {
 ...
 }
 /* common.h */
 #define USER “sa”
 #define PASSWORD ““
 ============================================================
 
 exec sql begin declare section;
         char    global_username[100];
         char    global_password[100];
 exec sql end declare section;
 
getinfo.c

        #include <common.h>
         printf(“uid?\n”);
         gets(global_username);
         printf(“password?\n”);
         gets(global_password);
 
do_connect.c
        exec sql include “common.h”;
         exec sql connect :global_username
           identified by :global_password;

Usage

See also

declare section