postgresql_16:5.3.4 Using Host Variables
PostgreSQL 16 > Client Interfaces > ECPG — Embedded SQL in C > Using Host Variables
In (see postgresql_16:5.3.3) you saw how you can execute SQL statements from an embedded SQL program. Some of those statements only used fixed values and did not provide a way to insert user-supplied values into statements or have the program process the values returned by the query. Those kinds of statements are not really useful in real applications. This section explains in detail how you can pass data between your C program and the embedded SQL statements using a simple mechanism called *host variables*. In an embedded SQL program we consider the SQL statements to be *guests* in the C program code which is the *host language*. Therefore the variables of the C program are called *host variables*.
Another way to exchange values between PostgreSQL backends and ECPG applications is the use of SQL descriptors, described in (see postgresql_16:5.3.7).
Subsections
- postgresql_16:5.3.4.1 Overview
- postgresql_16:5.3.4.2 Declare Sections
- postgresql_16:5.3.4.3 Retrieving Query Results
- postgresql_16:5.3.4.4 Type Mapping
- postgresql_16:5.3.4.5 Handling Nonprimitive SQL Data Types
- postgresql_16:5.3.4.6 Indicators