SQL descriptor areas

Dynamic SQL uses an SQL descriptor area (SQLDA) to pass information about an SQL statement between SQL and your application. A descriptor is required for running the DESCRIBE, DESCRIBE INPUT and DESCRIBE TABLE statements, and can also be used on the PREPARE, OPEN, FETCH, CALL, and EXECUTE statements.

The meaning of the information in an SQLDA depends on its use. In PREPARE and DESCRIBE, an SQLDA provides information to an application program about a prepared statement. In DESCRIBE INPUT, the SQL descriptor area provides information to an application program about parameter markers in a prepared statement. In DESCRIBE TABLE, the SQLDA provides information to an application program about the columns in a table or view. In OPEN, EXECUTE, CALL, and FETCH, an SQLDA provides information about host variables. For example, you can read values into the SQLDA using a DESCRIBE statement, change the data values in the descriptor to use the host variables, and then reuse the same descriptor in a FETCH statement.

If your application allows you to have several cursors open at the same time, you can code several SQLDAs, one for each dynamic SELECT statement.

Start of changeThere are two types of SQLDAs. One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined using the SQLDA structure.End of change

Start of changeALLOCATE DESCRIPTOR is not supported in REXX. SQLDAs can be used in C, C++, COBOL, PL/I, REXX, and RPG. Because RPG/400 does not provide a way to set pointers, the SQLDA must be set outside the RPG/400 program by a PL/I, C, C++, COBOL, or ILE RPG program. That program must then call the RPG/400 program.End of change

Related information
SQLCA (SQL communications area)
SQLDA (SQL descriptor area)