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.
ecpg testproc.pgc
If an optimizer hint block comment is specified for the SQL statement, specify the following option in the ecpg command:
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.
EXEC SQL SELECT /*+ IndexScan(prod ix01) */ name_id INTO :name_id FROM prod WHERE id = 1;
See
For basic usage of pg_hint_plan and pg_dbms_stats, see below.
Control execution plans with pg_hint_plan
https://www.postgresql.fastware.com/postgresql-insider-tun-hint-plan
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 paths when compiling a C application output with precompiling.
Refer to your compiler documentation for information on how to specify the path.
Also, when using a shared library, refer to "A.6 How to Build and Run an Application that Uses Shared Libraries".
Type of path | Path name |
---|---|
Path of the include file | fujitsuEnterprisePostgresClientInstallDir/include |
Path of the library | fujitsuEnterprisePostgresClientInstallDir/lib |
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 |
If the include file and the library path have been set in the environment variable, there is no need to specify the paths shown below for the compile.
Type of path | Path name |
---|---|
Path of the include file | fujitsuEnterprisePostgresClientInstallDir\include |
Path of the library | fujitsuEnterprisePostgresClientInstallDir\lib |
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(R) 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.)