About persistent binding

To pass values to Adaptive Server and to store values from it, an Embedded SQL program uses host variables—C variables recognized by Embedded SQL. The program associates these variables with values on Adaptive Server. For example, the following select statement associates the host output variable last with a row value retrieved from Adaptive Server:

id = “998-72-3567”;
 exec sql select au_lname into :last
 from authors where au_id = :id;

The statement passes its host input variable, id, to Adaptive Server and associates that variable with the server’s au_id column.

The act of associating a statement’s host variables with Adaptive Server values is called binding. The association itself is also called a binding. Host input variables use only input bindings; host output variable use only output bindings.

Binding governs which data a statement retrieves from the server. If a statement binds a host variable to the wrong server data, the statement will retrieve the wrong value for that host variable. However, unnecessary binding can slow a program’s performance.

Embedded SQL lets you control how long bindings remain in effect—how long they “persist.” A binding that persists for more than one execution of a statement is called a persistent binding. Persistent bindings enable some Embedded SQL statements to execute faster, thereby improving a program’s performance.

In Embedded SQL, each binding is made possible by a Client-Library command structure—a data structure that, among other things, defines the bindings of an Embedded SQL statement. For each Embedded SQL statement that executes, there is a corresponding command structure. A single command structure, however, can be used by more than one statement. In fact, when bindings persist from one Embedded SQL statement to another, they do so because the statements share a single command structure.

An Embedded SQL program’s source code does not explicitly declare or allocate command structures. Instead, command structures are declared and allocated by the program’s generated code.