CXU - Examples

In order to take full advantage of the following examples you need to have CXU installed and to have defined a CXU-key. You also need an active ISPF EDIT or VIEW session. Whether you use a new dataset/member or an existing is up to you, but you must be prepared to change data. Examples:

         Display the contents of a dataset or member
         Execute a SQL statement
         Display the columns in a DB2 table
         Execute SQL statement containing hostvariables within program source
         Display list of selected datasets or members

Display the contents of a dataset or member

Place the cursor on any character (except a dot) in an existing datasetname or datasetname(membername). Press your CXU-key. The contents of the dataset or member is displayed in a new ISPF EDIT/VIEW/BROWSE session or as a member list. CXU determines how the contents should be presented to you. Read more here.

Hint: CXU does not have any requirements regarding dataset names or the data contents (JCL, program source or the like). Thus it is a good idea to create a dataset or member containing the dataset names you prefer to work with. Using the CXU-key you can go from this dataset or member to the datasets or members you need to access for various purposes.

Execute a SQL statement

Type in the following SQL statement as an example. It should work on all DB2 systems:

SELECT *
FROM sysibm.systables
WHERE creator = 'SYSIBM'
;
Place the cursor somewhere on the word SELECT. Press your CXU-key. CXU detects which DB2 systems are available and if only one DB2 system is available your SQL statement is executed and the result is displayed in an ISPF VIEW session. If more than one DB2 system is available CXU will display a list of the systems just below the first line in the SQL statement. Follow the guidance in the corresponding ISPF message. Press F1 (HELP) if you need a more adequate description. Then place the cursor on SELECT again and press the CXU-key. The result is now displayed in an ISPF VIEW-session. Read more here.

Display the columns in a DB2 table

Begin with the example Execute a SQL statement. When it works place the cursor somewhere on the table name (except the dot) and press your CXU-key. CXU now displays a list of the indexes and columns in the selected table directly below the line containing the table name.

Hint: CXU does not require a table name to be located inside a SQL statement. Thus you are able to display the columns of a DB2 table just by typing a table name, place the cursor on it and press the CXU-key. Read more here.

Execute SQL statement containing hostvariables within program source

Begin with the example Execute a SQL statement. When it works then change the example to the following (remember to add the &DB2SYS-parameter in a comment, if applicable):

SELECT *
-- &CREATOR=sysibm &:schema='SYSIBM'
FROM systables
WHERE creator = :schema
;
Again place the cursor somewhere on the word SELECT and press your CXU-key. Again the result is displayed in an ISPF VIEW session and it is by the way the same result as before you changed the SQL statement. &CREATOR= defines the creator for all tables without creator in the SQL statement while &:schema='SYSIBM' defines a variable called schema and assigns it the value 'SYSIBM'. When CXU scans the SQL statement and discovers a hostvariable with an identical name (schema) then :schema is replaced with the value 'SYSIBM' and then CXU executes the SQL statement.

The example uses -- as comment. You can also use * in position 1 and 7 and /* */ as comments. All these types of comments supported by CXU makes it possible to execute the example and all other types of SQL statementes directly from the program source. If you use comments in compliance with the source you can compile the program without errors using the &-parameters in comments within the SQL statement. Read more about hostvariables here.

Display list of selected datasets or members

Place the cursor on a dot in an existing dataset name. Press your CXU-key. A list of datasets beginning with the selected dataset name is displayed using ISPF DSLIST (ISPF 3.4). Normally only one dataset will be listed, but if other datasets begins with the name of the selected dataset name, they will appear on the list. Read more here.

Type in asteriks (*) or percent (%) in a dataset name. Place the cursor somewhere on the changed dataset name. Press your CXU-key. A list of datasets matching your dataset filter is displayed using ISPF DSLIST (ISPF 3.4). Read more here.

Type in asteriks (*) or percent (%) in the member name of a datasetname(membername). Place the cursor somewhere on the changed datasetname(membername). Press your CXU-key. A list of members matching your member filter is displayed using ISPF MEMLIST (ISPF 3.1). Read more here.