跳至主要內容

KlustronDB大约 2 分钟

Chapter 36. ECPG - Embedded SQL in C

Table of Contents

36.1. The Concept

36.2. Managing Database Connections : 36.2.1. Connecting to the Database Server

[36.2.2. Choosing a Connection](ecpg-connect.md#ECPG-SET-CONNECTION)

[36.2.3. Closing a Connection](ecpg-connect.md#ECPG-DISCONNECT)

36.3. Running SQL Commands : 36.3.1. Executing SQL Statements

[36.3.2. Using Cursors](ecpg-commands.md#ECPG-CURSORS)

[36.3.3. Managing Transactions](ecpg-commands.md#ECPG-TRANSACTIONS)

[36.3.4. Prepared Statements](ecpg-commands.md#ECPG-PREPARED)

36.4. Using Host Variables : 36.4.1. Overview

[36.4.2. Declare Sections](ecpg-variables.md#ECPG-DECLARE-SECTIONS)

[36.4.3. Retrieving Query Results](ecpg-variables.md#ECPG-RETRIEVING)

[36.4.4. Type Mapping](ecpg-variables.md#ECPG-VARIABLES-TYPE-MAPPING)

[36.4.5. Handling Nonprimitive SQL Data Types](ecpg-variables.md#ECPG-VARIABLES-NONPRIMITIVE-SQL)

[36.4.6. Indicators](ecpg-variables.md#ECPG-INDICATORS)

36.5. Dynamic SQL : 36.5.1. Executing Statements without a Result Set

[36.5.2. Executing a Statement with Input Parameters](ecpg-dynamic.md#ECPG-DYNAMIC-INPUT)

[36.5.3. Executing a Statement with a Result Set](ecpg-dynamic.md#ECPG-DYNAMIC-WITH-RESULT)

36.6. pgtypes Library : 36.6.1. Character Strings

[36.6.2. The numeric Type](ecpg-pgtypes.md#ECPG-PGTYPES-NUMERIC)

[36.6.3. The date Type](ecpg-pgtypes.md#ECPG-PGTYPES-DATE)

[36.6.4. The timestamp Type](ecpg-pgtypes.md#ECPG-PGTYPES-TIMESTAMP)

[36.6.5. The interval Type](ecpg-pgtypes.md#ECPG-PGTYPES-INTERVAL)

[36.6.6. The decimal Type](ecpg-pgtypes.md#ECPG-PGTYPES-DECIMAL)

[36.6.7. errno Values of pgtypeslib](ecpg-pgtypes.md#ECPG-PGTYPES-ERRNO)

[36.6.8. Special Constants of pgtypeslib](ecpg-pgtypes.md#ECPG-PGTYPES-CONSTANTS)

36.7. Using Descriptor Areas : 36.7.1. Named SQL Descriptor Areas

[36.7.2. SQLDA Descriptor Areas](ecpg-descriptors.md#ECPG-SQLDA-DESCRIPTORS)

36.8. Error Handling : 36.8.1. Setting Callbacks

[36.8.2. sqlca](ecpg-errors.md#ECPG-SQLCA)

[36.8.3. `SQLSTATE` vs. `SQLCODE`](ecpg-errors.md#ECPG-SQLSTATE-SQLCODE)

36.9. Preprocessor Directives : 36.9.1. Including Files

[36.9.2. The define and undef Directives](ecpg-preproc.md#ECPG-DEFINE)

[36.9.3. ifdef, ifndef, else, elif, and endif Directives](ecpg-preproc.md#ECPG-IFDEF)

36.10. Processing Embedded SQL Programs

36.11. Library Functions

36.12. Large Objects

36.13. C++ Applications : 36.13.1. Scope for Host Variables

[36.13.2. C++ Application Development with External C Module](ecpg-cpp.md#ECPG-CPP-AND-C)

36.14. Embedded SQL Commands : ALLOCATE DESCRIPTOR — allocate an SQL descriptor area

[CONNECT](ecpg-sql-connect.md) — establish a database connection

[DEALLOCATE DESCRIPTOR](ecpg-sql-deallocate-descriptor.md) — deallocate an SQL descriptor area

[DECLARE](ecpg-sql-declare.md) — define a cursor

[DESCRIBE](ecpg-sql-describe.md) — obtain information about a prepared statement or result set

[DISCONNECT](ecpg-sql-disconnect.md) — terminate a database connection

[EXECUTE IMMEDIATE](ecpg-sql-execute-immediate.md) — dynamically prepare and execute a statement

[GET DESCRIPTOR](ecpg-sql-get-descriptor.md) — get information from an SQL descriptor area

[OPEN](ecpg-sql-open.md) — open a dynamic cursor

[PREPARE](ecpg-sql-prepare.md) — prepare a statement for execution

[SET AUTOCOMMIT](ecpg-sql-set-autocommit.md) — set the autocommit behavior of the current session

[SET CONNECTION](ecpg-sql-set-connection.md) — select a database connection

[SET DESCRIPTOR](ecpg-sql-set-descriptor.md) — set information in an SQL descriptor area

[TYPE](ecpg-sql-type.md) — define a new data type

[VAR](ecpg-sql-var.md) — define a variable

[WHENEVER](ecpg-sql-whenever.md) — specify the action to be taken when an SQL statement causes a specific class condition to be raised

36.15. Informix Compatibility Mode : 36.15.1. Additional Types

[36.15.2. Additional/Missing Embedded SQL Statements](ecpg-informix-compat.md#ECPG-INFORMIX-STATEMENTS)

[36.15.3. Informix-compatible SQLDA Descriptor Areas](ecpg-informix-compat.md#ECPG-INFORMIX-SQLDA)

[36.15.4. Additional Functions](ecpg-informix-compat.md#ECPG-INFORMIX-FUNCTIONS)

[36.15.5. Additional Constants](ecpg-informix-compat.md#ECPG-INFORMIX-CONSTANTS)

36.16. Internals

This chapter describes the embedded SQL package for PostgreSQL. It was written by Linus Tolke (<linus@epact.se>) and Michael Meskes (<meskes@postgresql.org>). 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.