Chapter 38. ECPG — Embedded SQL in C

Table of Contents

38.1. The Concept
38.2. Managing Database Connections
38.2.1. Connecting to the Database Server
38.2.2. Choosing a Connection
38.2.3. Closing a Connection
38.3. Running SQL Commands
38.3.1. Executing SQL Statements
38.3.2. Using Cursors
38.3.3. Managing Transactions
38.3.4. Prepared Statements
38.4. Using Host Variables
38.4.1. Overview
38.4.2. Declare Sections
38.4.3. Retrieving Query Results
38.4.4. Type Mapping
38.4.5. Handling Nonprimitive SQL Data Types
38.4.6. Indicators
38.5. Dynamic SQL
38.5.1. Executing Statements without a Result Set
38.5.2. Executing a Statement with Input Parameters
38.5.3. Executing a Statement with a Result Set
38.6. pgtypes Library
38.6.1. Character Strings
38.6.2. The numeric Type
38.6.3. The date Type
38.6.4. The timestamp Type
38.6.5. The interval Type
38.6.6. The decimal Type
38.6.7. errno Values of pgtypeslib
38.6.8. Special Constants of pgtypeslib
38.7. Using Descriptor Areas
38.7.1. Named SQL Descriptor Areas
38.7.2. SQLDA Descriptor Areas
38.8. Error Handling
38.8.1. Setting Callbacks
38.8.2. sqlca
38.8.3. SQLSTATE vs. SQLCODE
38.9. Preprocessor Directives
38.9.1. Including Files
38.9.2. The define and undef Directives
38.9.3. ifdef, ifndef, elif, else, and endif Directives
38.10. Processing Embedded SQL Programs
38.11. Library Functions
38.12. Large Objects
38.13. C++ Applications
38.13.1. Scope for Host Variables
38.13.2. C++ Application Development with External C Module
38.14. Embedded SQL Commands
ALLOCATE DESCRIPTOR — allocate an SQL descriptor area
CONNECT — establish a database connection
DEALLOCATE DESCRIPTOR — deallocate an SQL descriptor area
DECLARE — define a cursor
DECLARE STATEMENT — declare SQL statement identifier
DESCRIBE — obtain information about a prepared statement or result set
DISCONNECT — terminate a database connection
EXECUTE IMMEDIATE — dynamically prepare and execute a statement
GET DESCRIPTOR — get information from an SQL descriptor area
OPEN — open a dynamic cursor
PREPARE — prepare a statement for execution
SET AUTOCOMMIT — set the autocommit behavior of the current session
SET CONNECTION — select a database connection
SET DESCRIPTOR — set information in an SQL descriptor area
TYPE — define a new data type
VAR — define a variable
WHENEVER — specify the action to be taken when an SQL statement causes a specific class condition to be raised
38.15. Informix Compatibility Mode
38.15.1. Additional Types
38.15.2. Additional/Missing Embedded SQL Statements
38.15.3. Informix-compatible SQLDA Descriptor Areas
38.15.4. Additional Functions
38.15.5. Additional Constants
38.16. Oracle Compatibility Mode
38.17. Internals

This chapter describes the embedded SQL package for Postgres Pro. 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.