The ESQL/C preprocessor

To preprocess, compile, and link a program that contains statements, you must pass it through the preprocessor. You use the esql command to run the preprocessor on your source file and create an executable file. The esql command follows these steps to carry out the conversion:
  • In stage one, the preprocessor performs the following steps:
    • Incorporates header files into the source file when it processes all include directives ($include and EXEC SQL include statements)
    • Creates or removes compile-time definitions when it processes all define ($define and EXEC SQL define) and undef ($undef and EXEC SQL undef) directives
  • In stage two, the preprocessor processes any conditional compilation directives (ifdef, ifndef, else, elif, endif) and translates embedded SQL statements to function calls and special data structures.

    Stages 1 and 2 mirror the preprocessor and compiler stages of the C compiler. Successful completion of the preprocessing step yields a C source file (.c extension). For information about command-line options that affect the preprocessing step, see Options that affect preprocessing.

The esql command processor is installed as part of the product. Before you use esql, ensure that:
  • The file name of the source file has the .ec or the .ecp.
  • The ONEDB_HOME and PATH environment variables are set correctly.

    If the ONEDB_HOME environment variable is not set in the command window or in the Windows™ Registry, it is set internally to the location of the HCL® OneDB® Client SDK dynamically linked libraries.

    If the ONEDB_HOME environment variable is not set in UNIX™, an error is returned when compiling any HCL OneDB Client Software Development Kit (Client SDK) application.

    For information about how to set the ONEDB_HOME and PATH variables, see the HCL OneDB Client Products Installation Guide for your operating system.

For a detailed explanation of the syntax of the esql command, see The esql command.
Important: Always link your program with the esql program. The lists of libraries that HCL OneDB uses can change between releases. Linking with esql assures that your program links correctly with HCL OneDB libraries.

The C code that the preprocessor generates might change from one release of the product to the next. Therefore, do not design programs that depend on how HCL OneDB implements the functionality and features of the product in the C code that the preprocessor generates. Instead, develop your programs with the functionality and features of the product that this publication describes.