Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

6.4.2 Compiling Applications

Append the extension "pgc" to the name of the source file for the embedded SQL in C.

When the pgc file is precompiled using the ecpg command, C source files will be created, so use the C compiler for the compile.

Precompiling example

ecpg testproc.pgc

If an optimizer hint block comment is specified for the SQL statement, specify the following option in the ecpg command:

--enable-hint

Enables the optimizer hint block comment (hereafter, referred to as the "hint clause"). If this option is not specified, the hint clause will be removed as a result of the ecpg precompile and be disabled.

The SQL statements that can be specified in the hint clause are SELECT, INSERT, UPDATE, and DELETE.

The locations in which the hint clause can be specified are immediately after one of the SELECT, INSERT, UPDATE, DELETE, or WITH keywords. A syntax error will occur if any other location is specified.

Example of specifying the hint clause
EXEC SQL SELECT /*+ IndexScan(prod ix01) */ name_id INTO :name_id FROM prod WHERE id = 1;

Refer to "12.1.1 Optimizer Hints" for information on optimizer hints.


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.


Specify the following options when compiling a C application output with precompiling.

LinuxLinux
LinuxTable 6.1 Include file and library path

Option

How to specify the option

Path of the include file

-I/symfowareServerClientInstallDir/include

Path of the library

-L/symfowareServerClientInstallDir/lib

LinuxTable 6.2 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

WindowsWindows(R)

If the include file and the library path have been set in the environment variable, there is no need to specify the options shown below for the compile.

WindowsTable 6.3 Include file and library path

Type of option

How to specify the option

Path of the include file

SymfowareServerClientInstallDir\include

Path of the library

SymfowareServerClientInstallDir\lib

WindowsTable 6.4 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.)