v Host variables are not allowed within the SQL. Instead, you can use REXX variables to pass input data
to the EXECSQL environment. The REXX variables are not embedded within quotes. The output from
the EXECSQL environment is provided in REXX predefined variables (see section “Receiving the
Results”).
v When you code a SQL SELECT statement, you cannot use the INTO clause. Instead, the REXX/CICS
DB2 returns the requested items in compound variables with stem names equal to the DB2 column
names.
v The default number of rows returned for a SELECT statement is 250. If you need more or less rows,
you can set the REXX variable SQL_SELECT_MAX before issuing the SELECT statement.
Receiving the Results
The EXECSQL command environment returns results in predefined REXX variables. These variables are:
RC Each operation sets this return code. Possible values are:
n Specifies the SQLCODE if the SQL statement resulted in an error or warning.
0 The SQL statement was processed by the EXECSQL environment. The REXX variables
for the SQLCA contain the completion status of the SQL statement.
30 There was not enough memory to build the SQLDSECT variable.
31 There was not enough memory to build the SQL statement area.
32 There was not enough memory to build the SQLDA variable.
33 There was not enough memory to build the results area for the SELECT statement.
SQLCODE etc
A set of SQLCA variables are updated after SQL statements are processed. The entries of the
SQLCA are described in section “Using the SQL Communications Area” on page 288.
SQL_COLNAME.n
Contains the name of each DB2 column whose data was returned by a SELECT statement.
SQL_COLUMNS should be used as the maximum value for n.
SQL_COLTYPE.n
Contains the type of each DB2 column whose data was returned by a SELECT statement.
SQL_COLUMNS should be used as the maximum value for n.
Note: Although all data types are supported, not all are displayable. REXX functions can be used
to convert the data into the format desired.
For information about the meaning of specific SQLTYPE codes found in SQL_COLTYPE, see the
DB2 Server for VSE & VM SQL Reference, SC09-2671.
SQL_COLLEN.n
Contains the length of each DB2 column whose data was returned by a SELECT statement. If the
data type is DECIMAL, the scale is placed after the length of the column (after one blank space).
SQL_COLUMNS should be used as the maximum value for n.
SQL_COLUMNS
Contains the count of the number of columns returned.
column.n
The results of a SQL SELECT statement are stored in these REXX compound variables. The
column is the name of the DB2 column. Each item contains data for one row from DB2. The count
of the number of SQL rows returned is contained in column.0. The count should be used as the
maximum value for n.
DB2 Interface
Chapter 22. REXX/CICS DB2 Interface 287