Creating an ESQL/C program
About this task
To create an ESQL/C program:
Procedure
- Embed Informix®
ESQL/C statements
in a C-language source program to perform the following tasks:
- Define host variables to store data for transfer between the Informix® ESQL/C program and the database server.
- Access the database server through SQL statements.
- Provide directives for the Informix® ESQL/C preprocessor and the C compiler.
- Preprocess the Informix® ESQL/C source file with the esql command to create a C-language source file and start the C compiler.
- As necessary, correct errors reported by the preprocessor and the compiler and repeat step 2.
- Using the esql command, link the compiled object code into one or more executable files.
Results
The Informix®
ESQL/C source
file can contain the following types of statements:
- Preprocessor directives
- Informix®
ESQL/C preprocessor
directives to create simple macro definitions, include Informix®
ESQL/C files,
and perform conditional Informix®
ESQL/C compilation.
C preprocessor directives to create macro definitions, include system and C source files, and perform conditional C compilation.
- Language statements
- Informix®
ESQL/C host
variable definitions to store data for transfer between the Informix®
ESQL/C program
and the database server.
Embedded SQL statements to communicate with the database server.
C language statements to provide program logic.
For information about C preprocessor directives and C language statements, see a C programming text.
Your Informix®
ESQL/C source
code file name can have either of the following forms:
- esqlc_source.ec
- esqlc_source.ecp
The particular suffix that your Informix® ESQL/C source file has determines the default order in which that source file gets compiled by the esql command. The .ec suffix is the default suffix. For more information about the .ecp suffix and the non-default order of compilation, see Run the C preprocessor before the ESQL/C preprocessor.