DB2 REXX SQL for VM/ESA(R): Installation and Reference


Chapter 5. Getting Started with DB2 RXSQL

This chapter introduces the DB2 RXSQL interface by describing the elements of DB2 RXSQL, and how to access it.


What is DB2 RXSQL?

The DB2 REXX SQL for VM/ESA (DB2 RXSQL) allows REXX programs to access the DB2 Server for VM relational database management system.

SQL, the language used to interface to the database manager, can be imbedded in procedural languages such as assembler, C, COBOL, FORTRAN, and PL/I. DB2 RXSQL extends this support to REXX programs and allows SQL statements to be used in DB2 RXSQL requests contained in REXX programs.

DB2 RXSQL contains an expanded interface that resembles the standard SQL language (except for user descriptors), as outlined in the SAA Database Level 2 Reference manual.

Unlike the other host languages mentioned, DB2 RXSQL requests are not preprocessed. Compiling your REXX programs has no effect on the DB2 RXSQL requests contained in them.

DB2 RXSQL supports the use of both Dynamic and Extended Dynamic SQL statements.

DB2 RXSQL performs some initial checking on these statements, transforms them into standard run-time SQL operations, and passes them to the database manager. Results of these SQL operations are returned to your program in REXX variables. This includes both data and resulting status information.

When you are coding DB2 RXSQL operations in a REXX program, you can use REXX variables to do the following:

DB2 RXSQL consists of two modules:

  1. RXSQL, which loads a CMS nucleus extension
  2. EXECSQL, which passes control to RXSQL.

DB2 RXSQL also includes a DB2 RXSQL LOADLIB which gets loaded as a CMS nucleus extension.


What You Get with DB2 RXSQL

With DB2 RXSQL, you receive DB2 RXSQL-supplied programs, sample REXX programs, and online HELP information. You can use these along with the DB2 RXSQL requests that come with DB2 RXSQL to create your own applications.

DB2 RXSQL-Supplied Programs

RXCASE
Sets a global variable for the case setting of SQL statements to be used by the RXSELECT and RXSQLEX EXECs.

RXSELECT
Retrieves rows from the database and displays them in a temporary file, S$Q$L S$T$M$T, using XEDIT.

RXSQLANG
Sets global variables for determining languages that the HELP text and messages will be in when displayed using the RXSQLHLP EXEC.

RXSQLEX
Issues an SQL EXECUTE IMMEDIATE statement to execute a valid SQL statement.

RXSQLHLP
Provides HELP information pertaining to DB2 RXSQL return codes, DB2 RXSQL messages, and HELP topics provided by the database manager. The HELP topics provided by the database manager may also be displayed using the ISQL HELP command when using ISQL.

RXSQLOP
Executes a valid SHOW or COUNTER operator command and displays the output in the file S$Q$L O$P, using XEDIT.

RXSQLVL
Displays or stacks the current release level of DB2 RXSQL that is installed.

For further information, refer to Chapter 6, RXSQL-Supplied Programs.

Sample Programs

These programs are examples of how to use DB2 RXSQL statements in your own REXX programs.

EMPCRE
Creates a table and a view that are used by the rest of the sample programs. It also loads data into the table.

EMPSEL
Selects data from the table.

EMPPRP
Creates a package using Extended Dynamic SQL and generates the EMPDCL program.

EMPDCL
Declares a cursor and associates it with a statement in the package created by the EMPPRP program.

EMPSELX
Selects data from the table using Extended Dynamic SQL.

EMPPRPM
Creates a package for updating the table using Extended Dynamic SQL and generates the EMPDCLM program.

EMPDCLM
Declares cursors for statements in the package created by the EMPPRPM program.

EMPUPD
Updates the table interactively.

Refer to Appendix F, Sample Programs with Examples of RXSQL Requests for more information.

DB2 RXSQL Requests

DB2 RXSQL supports a variety of commands and statements which are listed in Chapter 10, RXSQL Request Descriptions.

If you are unfamiliar with SQL you can read Chapter 7, Concepts for an introduction to the way that DB2 RXSQL is used within REXX programs.

Online HELP

Use the CMS HELP command to obtain HELP information on these topics:

RXCASE
RXCMDS
RXSELECT
RXSQLANG
RXSQLEX
RXSQLHLP
RXSQLOP
RXSQLVL
RXUSAGE.

For further information, see HELP RXSQL MENU.


How to Access DB2 RXSQL

Before using DB2 RXSQL, ensure that it is installed and that you have access to the DB2 Server for VM database manager.

Link the Appropriate Disks

If DB2 RXSQL and the DB2 Server for VM program are installed on minidisks, access the DB2 Server for VM production minidisk and the DB2 RXSQL production minidisk by using the CP LINK and ACCESS commands.

If DB2 RXSQL and the DB2 Server for VM product are installed on minidisks using the defaults specified in Chapter 2, Installing DB2 RXSQL, then you can access the DB2 Server for VM and DB2 RXSQL production minidisks by typing the following commands:

   CP LINK SQLMACH 195 195 RR
   ACCESS 195 Q
   CP LINK SQLMACH 198 198 RR
   ACCESS 198 P

The name of the database machine (SQLMACH) and the minidisk numbers (195 and 198) may be different if DB2 RXSQL or the database manager are not installed using the defaults. Ask your database administrator about your installation's setup.

If the database manager and DB2 RXSQL are installed using SFS directories, type the following ACCESS commands:

   ACCESS VMSYS:SQLMACH.SQL.PRODUCTION Q
   ACCESS VMSYS:SQLMACH.RXSQL.PRODUCTION P

The names of the SFS directories, VMSYS:SQLMACH.SQL.PRODUCTION and VMSYS:SQLMACH.RXSQL.PRODUCTION may be different if DB2 RXSQL is not installed using the defaults.

Connect to the Application Server

If you are accessing the DB2 Server for VM application server for the first time, type the following command, substituting the name of your application server to establish a connection to it.

   SQLINIT DBNAME(server_name)

The application server is now available for use by DB2 RXSQL or other applications that use the DB2 Server for VM relational database manager.

Access the CMS Message Repository

DB2 RXSQL uses the CMS message repository for storing its error messages. Consequently, you must issue the following CMS command before beginning an DB2 RXSQL session:

   SET LANGUAGE (ADD ELO USER


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]