About this task
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.
- 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.
- SQLCOLn.1
- Some SELECT functions such as CURRENT SQLID, MAX, and AVG are
not associated with a particular DB2 column. To view the results you
must reference column name SQLCOLn.1.
The n begins
with, and is incremented by one, for each function included in the
SELECT statement. All columns represented by SQLCOLn appear
in the SQL_COLNAME compound variable.