REXX RUNSQL Directory
Directory .ZIPThese items include RUNSQL, a command that gives access to SQL statements from a command line or within a CLP. There are numerous variations of this facility available all over the Internet and most of them are better to use than the version here. This version is not presented as a high quality alternative, but rather as an example of simple REXX programming and using a REXX procedure in place of a command-processing program written in a HLL.
This version works mostly as well as any written purely in CL or RPG. The major irritation here is the same one that shows up in most REXX procedures run on an AS/400 -- that is the initiation time is relatively long. Briefly, when a REXX procedure is started in a session, OS/400 creates a session environment for REXX to work within. This takes noticeable time. But fortunately, this time is usually only taken once in a session. If multiple REXX procedures are run, the second, third and later runs do not take significant time to start.
Like many other RUNSQL implementations, this one relies on a Query Manager query. The QM Query source is simply a series of substitution variables. The variables are replaced by consecutive sub-strings from the incoming SQL statement parm and result in a complete SQL statement.
- To create the QM Query:
- CRTQMQRY QMQRY(mylib/CLSQL) SRCFILE(mylib/myqrysrcf)
Please read the @GENERAL DISCLAIMER document for any items you should be aware of if you download any of these items.
CMDs
RUNSQL -- Run SQL Statement:
The command definition object source for RUNSQL. This command accepts parameters providing an SQL statement and output options for display, print or outfile.The SQL statement is limited to 999 characters. By adding additional substitution variables to the QM Query source and altering the REXX procedure to include the new variables, the length can be extended. The SQL parm could also be made variable in length as long as the REXX procedure handles the length prefix.
QMQRYs
CLSQL -- QM Query definition:
The QM Query definition source for CLSQL. This QM query definition defines the substitution variables that will be replaced by substrings from the incoming SQL statement.
REXXs
RUNSQL -- Run SQL Statement:
The REXX procedure source for RUNSQL. This REXX procedure breaks up the incoming SQL statement into substring pieces to fit the QM Query substitution variables (max 55 characters per substitution variable, a restriction of QM) and selects the format of the STRQMQRY command based on output type requested.