Use the SQLEXEC routine to process all SQL statements. The character string arguments for the SQLEXEC routine are made up of the following elements:
Make each request by passing a valid SQL statement to the SQLEXEC routine. Use the following syntax:
CALL SQLEXEC 'statement'
SQL statements can be continued onto more than one line. Each part of the statement should be enclosed in single quotation marks, and a comma must delimit additional statement text as follows:
CALL SQLEXEC 'SQL text', 'additional text', . . . 'final text'
The following is an example of embedding an SQL statement in REXX:
statement = "UPDATE STAFF SET JOB = 'Clerk' WHERE JOB = 'Mgr'" CALL SQLEXEC 'EXECUTE IMMEDIATE :statement' IF ( SQLCA.SQLCODE < 0) THEN SAY 'Update Error: SQLCODE = ' SQLCA.SQLCODE
In this example, the SQLCODE field of the SQLCA structure is checked to determine whether the update was successful.
The following rules apply to embedded SQL statements:
Other SQL statements must be processed dynamically using the EXECUTE IMMEDIATE, or PREPARE and EXECUTE statements in conjunction with the SQLEXEC routine.
The cursor name identifier is used for DECLARE, OPEN, FETCH, and CLOSE statements. It identifies the cursor used in the SQL request.
The statement name identifier is used with the DECLARE, DESCRIBE, PREPARE, and EXECUTE statements.
The pre-declared identifiers must be used for cursor and statement names. Other names are not allowed.