Application Development Guide


Embedding SQL Statements in REXX

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:


[ Top of Page | Previous Page | Next Page ]