Invoke the ESQL/C filter

The esql command can automatically call the HCL OneDB™ ESQL/C filter, esqlmf, to process non-ASCII characters.

The following figure shows how the HCL OneDB ESQL/C program that contains non-ASCII characters becomes an executable program.
Figure 1: Create an ESQL/C executable program from a non-ASCII source program

The figure shows how the HCL OneDB ESQL/C program that contains non-ASCII characters becomes an executable program.
When you set the following environment variables, you tell esql how to invoke esqlmf:
  • The ESQLMF environment variable indicates whether esql automatically calls the HCL OneDB ESQL/C filter.

    When you set ESQLMF to 1, esql automatically calls esqlmf after the HCL OneDB ESQL/C preprocessor and before the C compiler.

  • The CC8BITLEVEL environment variable indicates the non-ASCII characters in the HCL OneDB ESQL/C source file that esqlmf filters.

    Set CC8BITLEVEL to indicate the ability of your C compiler to process non-ASCII characters.

How esqlmf filters the HCL OneDB ESQL/C source file depends on the value of the CC8BITLEVEL environment variable. For each value of CC8BITLEVEL, the following table shows the esqlmf command that the HCL OneDB ESQL/C processor invokes on the HCL OneDB ESQL/C source file.
CC8BITLEVEL The esqlmf action
0 Converts all non-ASCII characters, in literal strings and comments, to octal constants.
1 Converts non-ASCII characters in literal strings, but not in comments, to octal constants.
2 Converts non-ASCII characters in literal strings to octal constants to ensure that all the bytes in the non-ASCII characters have the eighth bit set.
3 Does not invoke esqlmf.
Important: To start the esqlmf commands that CC8BITLEVEL can specify, you must set the ESQLMF environment variable to 1.
When you set CC8BITLEVEL to 0, 1, or 2, the HCL OneDB ESQL/C processor performs the following steps:
  1. Converts the embedded-language statements (source.ec) to C-language source code (source.c) with the HCL OneDB ESQL/C preprocessor
  2. Filters non-ASCII characters in the preprocessed file (source.c) with the HCL OneDB ESQL/C filter, esqlmf (if the ESQLMF environment variable is 1)

    Before esqlmf begins filtering, it creates a copy of the C source file (source.c) that has the .c_ file extension (source.c_).

  3. Compiles the filtered C source file (source.c) with the C compiler to create an object file (source.o)
  4. Links the object file with the HCL OneDB ESQL/C libraries and your own libraries to create an executable program

When you set CC8BITLEVEL to 3, the HCL OneDB ESQL/C processor omits step 2 in the preceding list.

If you do not set CC8BITLEVEL, then esql converts non-ASCII characters in literal strings and comments. You can modify the value of CC8BITLEVEL to reflect the capabilities of your C compiler.