C source is created by precompiling the embedded SQL in C source file with the ecpg command.
Note
Take the following points into account when using embedded SQL source files:
Multibyte codes expressed in SJIS or UTF-16 cannot be included in statements or host variable declarations specified in EXEC SQL.
Do not use UTF-8 with a byte order mark (BOM), because an error may occur during compilation if the BOM character is incorrectly recognized as the source code.
Multibyte characters cannot be used in host variable names.
It is not possible to use a TYPE name that contains multibyte characters, even though it can be defined.
Compile the C source with a C compiler.
ecpg testproc.pgc
Point
C source with the extension .c is created by precompiling source with the extension .pgc.
Specify the following options when compiling a C application output with precompiling.
Linux
Include file and library path
Architecture | Option | How to specify the option |
---|---|---|
32-bit | Path of the include file | -I/opt/symfoclient32/include |
Path of the library | -L/opt/symfoclient32/lib | |
64-bit | Path of the include file | -I/opt/symfoclient64/include |
Path of the library | -L/opt/symfoclient64/lib |
C Library
Type of library | Library name | Note |
---|---|---|
Dynamic library | libecpg.so | |
libpgtypes.so | When using the pgtypes library | |
Static library | libecpg.a | |
libpgtypes.a | When using the pgtypes library |
Example
This provides examples of compiling an application dynamically linking with the C library.
Linux 64-bit
gcc -I/opt/symfoclient64/include -L/opt/symfoclient64/lib -lecpg -lpgtypes testproc.c -o testproc
Linux 32-bit
gcc -I/opt/symfoclient32/include -L/opt/symfoclient32/lib -lecpg -lpgtypes testproc.c -o testproc
Windows
Include file and library path
Architecture | Type of option | How to specify the option |
---|---|---|
32-bit | Path of the include file |
|
Path of the library |
| |
64-bit | Path of the include file | %ProgramFiles%\Fujitsu\symfoclient64\include |
Path of the library | %ProgramFiles%\Fujitsu\symfoclient64\lib |
C Library
Type of library | Library name | Note |
---|---|---|
Library for links | libecpg.lib | |
libpgtypes.lib | When using the pgtypes library | |
Dynamic library | libecpg.dll | |
libpgtypes.dll | When using the pgtypes library |
Note
The libecpg library in Windows is created by "release" and "multithreaded" options. When using the ECPGdebug function included in this library, compile using the "release" and "multithreaded" flags in all programs that use this library. When you do this, use the "dynamic" flag if you are using libecpg.dll, and use the "static" flag if you are using libecpg.lib.
Refer to "Library Functions" in "Client Interfaces" in the PostgreSQL Documentation for information on the ECPGdebug function.
The cl command expects input to be a program that uses one of the following code pages, so convert the program to these code pages and then compile and link it (refer to the Microsoft documentation for details).
ANSI console code pages (example: Shift-JIS for Japanese)
UTF-16 little-endian with or without BOM (Byte Order Mark)
UTF-16 big-endian with or without BOM
UTF-8 with BOM
The cl command converts strings in a program to an ANSI console code page before generating a module, so the data sent to and received from the database server becomes an ANSI console code page. Therefore, set the coding system corresponding to the ANSI console code page as the coding system of the client.
Refer to "Character Set Support" in "Server Administration" in the PostgreSQL Documentation for information on how to set the client encoding system.
(Example: To use environment variables in Japanese, set SJIS in PGCLIENTENCODING.)
Example
This is an example of compiling a 32-bit application using the cl command on a 64-bit operating system.
> SET LIB=%ProgramFiles(x86)%\Fujitsu\symfoclient32\lib;%LIB% > SET INCLUDE=%ProgramFiles(x86)%\Fujitsu\symfoclient32\include;%INCLUDE% > cl testproc.c libecpg.lib libpgtypes.lib