← 返回命令列表

Linux command

ecpg 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Preprocess embedded SQL file

ecpg [file.pgc]

Specify output file

ecpg -o [output.c] [input.pgc]

Include search path

ecpg -I [/include/path] [file.pgc]

Enable compatibility mode

ecpg -C [INFORMIX] [file.pgc]

Generate header file

ecpg -h [file.pgc]

说明

ecpg is the PostgreSQL embedded SQL preprocessor. It converts C programs with embedded SQL statements into regular C code that uses the libpq library. The tool reads .pgc files containing EXEC SQL statements embedded in C code and generates standard C files that can be compiled and linked with PostgreSQL's libpq library. This enables database operations to be written directly in the application code rather than as separate SQL strings.

参数

-o _file_
Write output to file.
-I _directory_
Include search path.
-c
Generate C code (default).
-C _mode_
Compatibility mode (INFORMIX, INFORMIX_SE).
-D _name_
Define preprocessor symbol.
-h
Parse header file only.
-i
Parse system includes.
-t
Turn on autocommit.

FAQ

What is the ecpg command used for?

ecpg is the PostgreSQL embedded SQL preprocessor. It converts C programs with embedded SQL statements into regular C code that uses the libpq library. The tool reads .pgc files containing EXEC SQL statements embedded in C code and generates standard C files that can be compiled and linked with PostgreSQL's libpq library. This enables database operations to be written directly in the application code rather than as separate SQL strings.

How do I run a basic ecpg example?

Run `ecpg [file.pgc]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _file_ do in ecpg?

Write output to file.