Chapter 22. REXX/CICS DB2 Interface
The REXX/CICS DB2 Interface provides a means of executing SQL from a REXX exec. The SQL are
prepared and executed dynamically. The REXX/CICS DB2 interface provides the results of the SQL in
REXX predefined variables.
The REXX/CICS DB2 interface supports DB2 V7.1 and above. This chapter explains how to use the
interface to DB2 from REXX/CICS. If you need more information about SQL, refer to the DB2 SQL
Reference.
The following information is provided in this chapter:
v Programming considerations
v Embedding SQL
Programming Considerations
To embed SQL within a REXX exec, the host command environment must be changed. The ADDRESS
instruction, followed by the name of the environment, is used to change the host command environment.
The ADDRESS instruction has two forms; one affects all commands issued after the instruction, and one
affects only a single command. For more information about host command environments, see section
“Changing the Host Command Environment” on page 83 and for more information about the ADDRESS
instruction, see section “ADDRESS” on page 132.
The REXX/CICS command environment that supports the REXX/CICS DB2 is:
EXECSQL
the command environment that supports SQL.
Note: EXECSQL is an authorized commands. You must be a REXX/CICS authorized user to use the
EXECSQL command environment.
REXX/CICS provides an exec called CICRXTRY that can be used to interactively process REXX
statements and commands. CICRXTRY can be pseudo-conversational. The PSEUDO and SETSYS
PSEUDO commands are used to turn pseudo-conversational mode on or off. If the environment is set to
pseudo-conversational, SQL statements issued from CICRXTRY will be committed. If the environment is
set to conversational, any SQL statements issued from the CICRXTRY exec will not be committed and any
resources that are locked will remain locked until you exit the CICRXTRY exec or issue a CICS
SYNCPOINT command. Similar considerations should be made if embedding SQL statements in lengthy
REXX execs.
Embedding SQL Statements
You can use the EXECSQL command environment to process the SQL. Each SQL statement is prepared
and executed dynamically using the CICS/DB2 attachment facility.
You can make each request by writing a valid SQL statement as a REXX command directed to the
EXECSQL environment. The SQL statement is made up of the following elements:
v SQL keywords
v Pre-declared identifiers
v Literal values.
Use the following syntax:
"EXECSQL statement"
or
© Copyright IBM Corp. 1992, 2009 285