--- title: "ECPG — Embedded SQL in C" id: ecpg pg_version: "20devel" --- # ECPG — Embedded SQL in C ## Table of Contents - [34.1. The Concept](ecpg-concept.md) - [34.2. Managing Database Connections](ecpg-connect.md) - [34.2.1. Connecting to the Database Server](ecpg-connect.md#ecpg-connecting) - [34.2.2. Choosing a Connection](ecpg-connect.md#ecpg-set-connection) - [34.2.3. Closing a Connection](ecpg-connect.md#ecpg-disconnect) - [34.3. Running SQL Commands](ecpg-commands.md) - [34.3.1. Executing SQL Statements](ecpg-commands.md#ecpg-executing) - [34.3.2. Using Cursors](ecpg-commands.md#ecpg-cursors) - [34.3.3. Managing Transactions](ecpg-commands.md#ecpg-transactions) - [34.3.4. Prepared Statements](ecpg-commands.md#ecpg-prepared) - [34.4. Using Host Variables](ecpg-variables.md) - [34.4.1. Overview](ecpg-variables.md#ecpg-variables-overview) - [34.4.2. Declare Sections](ecpg-variables.md#ecpg-declare-sections) - [34.4.3. Retrieving Query Results](ecpg-variables.md#ecpg-retrieving) - [34.4.4. Type Mapping](ecpg-variables.md#ecpg-variables-type-mapping) - [34.4.5. Handling Nonprimitive SQL Data Types](ecpg-variables.md#ecpg-variables-nonprimitive-sql) - [34.4.6. Indicators](ecpg-variables.md#ecpg-indicators) - [34.5. Dynamic SQL](ecpg-dynamic.md) - [34.5.1. Executing Statements without a Result Set](ecpg-dynamic.md#ecpg-dynamic-without-result) - [34.5.2. Executing a Statement with Input Parameters](ecpg-dynamic.md#ecpg-dynamic-input) - [34.5.3. Executing a Statement with a Result Set](ecpg-dynamic.md#ecpg-dynamic-with-result) - [34.6. pgtypes Library](ecpg-pgtypes.md) - [34.6.1. Character Strings](ecpg-pgtypes.md#ecpg-pgtypes-cstrings) - [34.6.2. The numeric Type](ecpg-pgtypes.md#ecpg-pgtypes-numeric) - [34.6.3. The date Type](ecpg-pgtypes.md#ecpg-pgtypes-date) - [34.6.4. The timestamp Type](ecpg-pgtypes.md#ecpg-pgtypes-timestamp) - [34.6.5. The interval Type](ecpg-pgtypes.md#ecpg-pgtypes-interval) - [34.6.6. The decimal Type](ecpg-pgtypes.md#ecpg-pgtypes-decimal) - [34.6.7. errno Values of pgtypeslib](ecpg-pgtypes.md#ecpg-pgtypes-errno) - [34.6.8. Special Constants of pgtypeslib](ecpg-pgtypes.md#ecpg-pgtypes-constants) - [34.7. Using Descriptor Areas](ecpg-descriptors.md) - [34.7.1. Named SQL Descriptor Areas](ecpg-descriptors.md#ecpg-named-descriptors) - [34.7.2. SQLDA Descriptor Areas](ecpg-descriptors.md#ecpg-sqlda-descriptors) - [34.8. Error Handling](ecpg-errors.md) - [34.8.1. Setting Callbacks](ecpg-errors.md#ecpg-whenever) - [34.8.2. sqlca](ecpg-errors.md#ecpg-sqlca) - [34.8.3. `SQLSTATE` vs. `SQLCODE`](ecpg-errors.md#ecpg-sqlstate-sqlcode) - [34.9. Preprocessor Directives](ecpg-preproc.md) - [34.9.1. Including Files](ecpg-preproc.md#ecpg-include) - [34.9.2. The define and undef Directives](ecpg-preproc.md#ecpg-define) - [34.9.3. ifdef, ifndef, elif, else, and endif Directives](ecpg-preproc.md#ecpg-ifdef) - [34.10. Processing Embedded SQL Programs](ecpg-process.md) - [34.11. Library Functions](ecpg-library.md) - [34.12. Large Objects](ecpg-lo.md) - [34.13. C++ Applications](ecpg-cpp.md) - [34.13.1. Scope for Host Variables](ecpg-cpp.md#ecpg-cpp-scope) - [34.13.2. C++ Application Development with External C Module](ecpg-cpp.md#ecpg-cpp-and-c) - [34.14. Embedded SQL Commands](ecpg-sql-commands.md) - [ALLOCATE DESCRIPTOR](ecpg-sql-allocate-descriptor.md) - [CONNECT](ecpg-sql-connect.md) - [DEALLOCATE DESCRIPTOR](ecpg-sql-deallocate-descriptor.md) - [DECLARE](ecpg-sql-declare.md) - [DECLARE STATEMENT](ecpg-sql-declare-statement.md) - [DESCRIBE](ecpg-sql-describe.md) - [DISCONNECT](ecpg-sql-disconnect.md) - [EXECUTE IMMEDIATE](ecpg-sql-execute-immediate.md) - [GET DESCRIPTOR](ecpg-sql-get-descriptor.md) - [OPEN](ecpg-sql-open.md) - [PREPARE](ecpg-sql-prepare.md) - [SET AUTOCOMMIT](ecpg-sql-set-autocommit.md) - [SET CONNECTION](ecpg-sql-set-connection.md) - [SET DESCRIPTOR](ecpg-sql-set-descriptor.md) - [TYPE](ecpg-sql-type.md) - [VAR](ecpg-sql-var.md) - [WHENEVER](ecpg-sql-whenever.md) - [34.15. Informix Compatibility Mode](ecpg-informix-compat.md) - [34.15.1. Additional Types](ecpg-informix-compat.md#ecpg-informix-types) - [34.15.2. Additional/Missing Embedded SQL Statements](ecpg-informix-compat.md#ecpg-informix-statements) - [34.15.3. Informix-compatible SQLDA Descriptor Areas](ecpg-informix-compat.md#ecpg-informix-sqlda) - [34.15.4. Additional Functions](ecpg-informix-compat.md#ecpg-informix-functions) - [34.15.5. Additional Constants](ecpg-informix-compat.md#ecpg-informix-constants) - [34.16. Oracle Compatibility Mode](ecpg-oracle-compat.md) - [34.17. Internals](ecpg-develop.md) This chapter describes the embedded SQL package for PostgreSQL. It was written by Linus Tolke () and Michael Meskes (). Originally it was written to work with C. It also works with C++, but it does not recognize all C++ constructs yet. This documentation is quite incomplete. But since this interface is standardized, additional information can be found in many resources about SQL.