In "REXX Fetches SQL" (see TechTalk, MC, December 1995), a tip was printed that illustrated how to use SQL in a REXX procedure. The author of the tip told the reader to use CMDENV(*EXECSQL) on the Start REXXProcedure (STRREXPRC) command in order for the SQL commands to be processed.
I would like to mention an alternative that is somewhat more flexible. My suggestion is to code the REXX command ADDRESS followed by the command environment that will execute the passed expression. In 4, you can see a segment of a procedure that I use to list a file.
I would like to mention an alternative that is somewhat more flexible. My suggestion is to code the REXX command ADDRESS followed by the command environment that will execute the passed expression. In Figure 4, you can see a segment of a procedure that I use to list a file.
The program in 4 goes on to use the SQL prepare, declare, open cursor, and fetch statements to print a report using the REXX SAY command. Using the ADDRESS command allows multiple command environments to be used from within REXX. It's also nice for those of us who tend to forget to change the parameter before pressing Enter on the STRREXPRC command.
The program in Figure 4 goes on to use the SQL prepare, declare, open cursor, and fetch statements to print a report using the REXX SAY command. Using the ADDRESS command allows multiple command environments to be used from within REXX. It's also nice for those of us who tend to forget to change the parameter before pressing Enter on the STRREXPRC command.
- Frank Hill
TechTalk: Here's another way to embed SQL in a REXX procedure.
Figure 4: Sample REXX Procedure Using the ADDRESS Command
ARG Wave RC = 0 ADDRESS COMMAND 'OVRDBF FILE(STDOUT) TOFILE(QSYSPRT)' ADDRESS EXECSQL EXECSQL 'SET OPTION COMMIT = *NONE' IF SQLCODE < 0 THEN SIGNAL ERROR SELECT_STMT = 'SELECT lane, type, length ', 'FROM wbpwawrk ', 'WHERE wave = ? ', 'ORDER BY lane' . . . ERROR: SAY 'Error occurred.'
LATEST COMMENTS
MC Press Online