Define SQL descriptor areas in RPG/400 applications that use SQL

Start of changeThere are two types of SQL descriptor areas. One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined using the SQLDA structure. In this topic, only the SQLDA form is discussed.End of change

Start of changeThe following statements can use an SQLDA:End of change

Start of changeUnlike the SQLCA, there can be more than one SQLDA in a program and an SQLDA can have any valid name.End of change

Dynamic SQL is an advanced programming technique. With dynamic SQL, your program can develop and then run SQL statements while the program is running. A SELECT statement with a variable SELECT list (that is, a list of the data to be returned as part of the query) that runs dynamically requires an SQL descriptor area (SQLDA). This is because you cannot know in advance how many or what type of variables to allocate in order to receive the results of the SELECT.

Because the SQLDA uses pointer variables which are not supported by RPG/400®, an INCLUDE SQLDA statement cannot be specified in an RPG/400 program. An SQLDA must be set up by a C, COBOL, PL/I, or ILE RPG program and passed to the RPG program in order to use it.

Related information
Dynamic SQL applications
SQL descriptor area