.\\" auto-generated by docbook2man-spec $Revision: 1.25 $ .TH "ECPG" "1" "2002-11-22" "Application" "PostgreSQL Client Applications" .SH NAME ecpg \- embedded SQL C preprocessor .SH SYNOPSIS .sp \fBecpg\fR\fR [ \fR\fB\fIoption\fB\fR...\fB \fR\fR]\fR \fB\fIfile\fB\fR...\fB\fR .SH "DESCRIPTION" .PP \fBecpg\fR 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. .PP \fBecpg\fR will convert each input file given on the command line to the corresponding C output file. Input files preferrably have the extension \fI.pgc\fR, in which case the extension will be replaced by \fI.c\fR to determine the output file name. If the extension of the input file is not \fI.pgc\fR, then the output file name is computed by appending .c to the full file name. The output file name can also be overridden using the \fB-o\fR option. .PP This reference page does not describe the embedded SQL language. See the \fIPostgreSQL Programmer's Guide\fR for that. .SH "OPTIONS" .PP \fBecpg\fR accepts the following command-line arguments: .TP \fB-c\fR Automatically generate C code from SQL code. Currently, this works for EXEC SQL TYPE. .TP \fB-D \fIsymbol\fB\fR Define a C preprocessor symbol. .TP \fB-I \fIdirectory\fB\fR Specify an additional include path, used to find files included via EXEC SQL INCLUDE. Defaults are \fI\&.\fR (current directory), \fI/usr/local/include\fR, the PostgreSQL include directory which is defined at compile time (default: \fI/usr/local/pgsql/include\fR), and \fI/usr/include\fR, in that order. .TP \fB-o \fIfilename\fB\fR Specifies that \fBecpg\fR should write all its output to the given \fIfilename\fR. .TP \fB-t\fR Turn on autocommit of transactions. In this mode, each query is automatically committed unless it is inside an explicit transaction block. In the default mode, queries are committed only when \fBEXEC SQL COMMIT\fR is issued. .TP \fB-v\fR Print additional information including the version and the include path. .TP \fB---help\fR Show a brief summary of the command usage, then exit. .TP \fB--version\fR Output version information, then exit. .PP .SH "NOTES" .PP When compiling the preprocessed C code files, the compiler needs to be able to find the \fBECPG\fR header files in the PostgreSQL include directory. Therefore, one might have to use the \fB-I\fR option when invoking the compiler (e.g., -I/usr/local/pgsql/include). .PP Programs using C code with embedded SQL have to be linked against the \fIlibecpg\fR library, for example using the flags -L/usr/local/pgsql/lib -lecpg. .PP The value of either of these directories that is appropriate for the installation can be found out using \fBpg_config\fR(1). .SH "EXAMPLES" .PP If you have an embedded SQL C source file named \fIprog1.pgc\fR, you can create an executable program using the following sequence of commands: .sp .nf ecpg prog1.pgc cc -I/usr/local/pgsql/include -c prog1.c cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg .sp .fi .SH "SEE ALSO" .PP \fIPostgreSQL Programmer's Guide\fR for a more detailed description of the embedded SQL interface