Processing SELECT statements and using a descriptor
The basic types of SELECT statements are fixed list and varying list.
To process a fixed-list SELECT statement, an SQL descriptor is not necessary.
To process a varying-list SELECT statement, first declare an SQL descriptor area (SQLDA) structure or ALLOCATE an SQLDA. Both forms of SQL descriptors can be used to pass host variable input values from an application program to SQL and to receive output values from SQL. In addition, information about SELECT list expressions can be returned in a PREPARE or DESCRIBE statement.
- Fixed-list SELECT statements
In dynamic SQL, a fixed-list SELECT statement retrieves data of a predictable number and type. When using this statement, you can anticipate and define host variables to accommodate the retrieved data so that an SQL descriptor area (SQLDA) is not necessary.
- Varying-list SELECT statements
In dynamic SQL, a varying-list SELECT statement is used when the number and format of the result columns are not predictable; that is, you do not know the data types or the number of variables that you need.
- SQL descriptor areas
Dynamic SQL uses an SQL descriptor area (SQLDA) to pass information about an SQL statement between SQL and your application.
- SQLDA format
An SQL descriptor area (SQLDA) consists of four variables followed by an arbitrary number of occurrences of a sequence of six variables collectively named SQLVAR.
- Example: A SELECT statement for allocating storage for SQLDA
Suppose that your application needs to handle a dynamic SELECT statement that changes from one use to the next. This statement can be read from a display, passed in from another application, or built dynamically by your application.
- Example: A SELECT statement using an allocated SQL descriptor
Suppose that your application needs to handle a dynamic SELECT statement that changes from one use to the next. This statement can be read from a display, passed from another application, or built dynamically by your application.
- Parameter markers
A parameter marker is a question mark (?) that appears in a dynamic statement string. The question mark can appear where a host variable might appear if the statement string were a static SQL statement.
Parent topic:
Dynamic SQL applications