バージョンごとのドキュメント一覧

ecpg

ecpg <refpurpose>embedded SQL C preprocessor</refpurpose> — 埋め込みSQL用Cプリプロセッサ

概要

ecpg [option...] file...

説明

<title>Description</title>

<command>ecpg</command> is the embedded SQL preprocessor for C programs. It converts C programs with embedded SQL statements to normal C code by replacing the SQL invocations with special function calls. The output files can then be processed with any C compiler tool chain. ecpgは、Cプログラム用の埋め込みSQLプリプロセッサです。 SQL呼び出しを特別な関数呼び出しに置き換えることによって、埋め込みSQL文を含むCプログラムを、通常のCコードに変換します。 これにより、出力ファイルは、任意のCコンパイラツールを使用して処理することができます。

<command>ecpg</command> will convert each input file given on the command line to the corresponding C output file. If an input file name does not have any extension, <filename>.pgc</filename> is assumed. The file's extension will be replaced by <filename>.c</filename> to construct the output file name. But the output file name can be overridden using the <option>-o</option> option. ecpgは、コマンドラインで指定される各入力ファイルを対応するCの出力ファイルに変換します。 入力ファイル名に拡張子がなければ、.pgcを仮定します。 出力ファイル名を構成するために、拡張子が.cに置き換えられます。 しかし、出力ファイル名は-oオプションによって指定でき、こちらが優先します。

If an input file name is just <literal>-</literal>, <command>ecpg</command> reads the program from standard input (and writes to standard output, unless that is overridden with <option>-o</option>). 入力ファイルが-だけであれば、ecpgはプログラムを標準入力から読み込み(-oで上書きされていなければ、標準出力へ書き出し)ます。

This reference page does not describe the embedded SQL language. See <xref linkend="ecpg"/> for more information on that topic. このマニュアルページでは埋め込みSQL言語については説明しません。 第36章を参照してください。

オプション

<title>Options</title>

<command>ecpg</command> accepts the following command-line arguments: ecpgは、以下のコマンドライン引数を受け付けます。

-c

Automatically generate certain C code from SQL code. Currently, this works for <literal>EXEC SQL TYPE</literal>. SQLコードから有効なCコードを自動的に生成します。 現在、このオプションはEXEC SQL TYPEに対して使用できます。

-C mode

Set a compatibility mode. <replaceable>mode</replaceable> can be <literal>INFORMIX</literal>, <literal>INFORMIX_SE</literal>, or <literal>ORACLE</literal>. 互換モードを設定します。 modeINFORMIXINFORMIX_SEORACLEのどれかを取ることができます。

-D symbol

Define a C preprocessor symbol. Cプリプロセッサのシンボルを定義します。

-h

Process header files. When this option is specified, the output file extension becomes <literal>.h</literal> not <literal>.c</literal>, and the default input file extension is <literal>.pgh</literal> not <literal>.pgc</literal>. Also, the <option>-c</option> option is forced on. ヘッダファイルを処理します。 このオプションが指定されると、出力ファイルの拡張子は.cではなく.hになり、デフォルトの入力ファイルの拡張子は.pgcではなく.pghになります。 また、-cオプションが強制的に有効になります。

-i

Parse system include files as well. 同様にシステムインクルードファイルも解析します。

-I directory

Specify an additional include path, used to find files included via <literal>EXEC SQL INCLUDE</literal>. Defaults are <filename>.</filename> (current directory), <filename>/usr/local/include</filename>, the <productname>PostgreSQL</productname> include directory which is defined at compile time (default: <filename>/usr/local/pgsql/include</filename>), and <filename>/usr/include</filename>, in that order. 追加のインクルード用パスを指定します。 これは、EXEC SQL INCLUDEを使用してインクルードされるファイルを検索する際に使用されます。 デフォルトでは順に、.(カレントディレクトリ)、/usr/local/include、コンパイル時に定義されるPostgreSQLのインクルードディレクトリ(デフォルトでは/usr/local/pgsql/include)、/usr/includeです。

-o filename

Specifies that <command>ecpg</command> should write all its output to the given <replaceable>filename</replaceable>. Write <literal>-o -</literal> to send all output to standard output. ecpgが全ての出力をfilenameに書き込むことを指定します。 出力をすべて標準出力に送るには-o -と書いてください。

-r option

Selects run-time behavior. <replaceable>Option</replaceable> can be one of the following: 実行時の動作を選択します。 以下のいずれかをoptionとして取ることができます。

no_indicator

Do not use indicators but instead use special values to represent null values. Historically there have been databases using this approach. 指示子を使用せずにNULL値を表す特殊な値を使用します。 歴史的にこの方式を使用したデータベースが存在します。

prepare

Prepare all statements before using them. Libecpg will keep a cache of prepared statements and reuse a statement if it gets executed again. If the cache runs full, libecpg will free the least used statement. すべての文を使用する前に準備(プリペア)します。 libecpgはプリペアド文のキャッシュを保持し、再実行される場合に文を再利用します。 キャッシュが満杯になった場合、libecpgは最も使用されていない文を解放します。

questionmarks

Allow question mark as placeholder for compatibility reasons. This used to be the default long ago. 互換性のためにクエスチョンマークをプレースホルダとして許します。 これは大昔にデフォルトでした。

-t

Turn on autocommit of transactions. In this mode, each SQL command is automatically committed unless it is inside an explicit transaction block. In the default mode, commands are committed only when <command>EXEC SQL COMMIT</command> is issued. トランザクションの自動コミットを有効にします。 このモードでは、各SQLコマンドは明示的なトランザクションブロックの内部にない限り、自動的にコミットされます。 デフォルトのモードでは、EXEC SQL COMMITが発行された時にのみコマンドがコミットされます。

-v

Print additional information including the version and the "include" path. バージョンやインクルード用パスなどの補足情報を表示します。

--version

Print the <application>ecpg</application> version and exit. ecpgのバージョンを表示し、終了します。

-?
--help

Show help about <application>ecpg</application> command line arguments, and exit. ecpgのコマンドライン引数の使用方法を表示し、終了します。

注釈

<title>Notes</title>

When compiling the preprocessed C code files, the compiler needs to be able to find the <application>ECPG</application> header files in the <productname>PostgreSQL</productname> include directory. Therefore, you might have to use the <option>-I</option> option when invoking the compiler (e.g., <literal>-I/usr/local/pgsql/include</literal>). 前処理されたCコードファイルをコンパイルする際、コンパイラがPostgreSQLのインクルードディレクトリ内にあるECPGヘッダファイルを検索できるようにしなければなりません。 そのため、コンパイラの呼び出し時に、-Iオプションを使用しなければならない可能性があります(例:-I/usr/local/pgsql/include)。

Programs using C code with embedded SQL have to be linked against the <filename>libecpg</filename> library, for example using the linker options <literal>-L/usr/local/pgsql/lib -lecpg</literal>. SQLが埋め込まれたCプログラムには、リンカオプション-L/usr/local/pgsql/lib -lecpgを使用するなどして、libecpgライブラリをリンクする必要があります。

The value of either of these directories that is appropriate for the installation can be found out using <xref linkend="app-pgconfig"/>. 使用するシステムにおいて上記の2つに対応するディレクトリを調べるには、pg_configを使用します。

<title>Examples</title>

If you have an embedded SQL C source file named <filename>prog1.pgc</filename>, you can create an executable program using the following sequence of commands: 埋め込みSQLを使用したprog1.pgcというCソースファイルがある場合、次のコマンドを順番に実行すれば、実行可能プログラムを作成することができます。

ecpg prog1.pgc
cc -I/usr/local/pgsql/include -c prog1.c
cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg