Joined: 03 Oct 2009 Posts: 1782 Location: Bloomington, IL
This is for SQL and DB2
There are several different interfaces between Rexx and DB2. Before attempting to use one, you must create an entry for it in the TSO environment table. Do this by coding:
name is whatever name you desire to call the DB2 environment; this name not be the same as the command handler.
handler is the name of the interface routine. It must be in a library in the linklist or that is allocated to STEPLIB. The standard IBM-supplied interface is DSNREXX; in my shop, however, we typically use the OpenSoftware interface RXTASQL.
Having established the environment, you may need to connect with a subsystem using DB2SET, DSNALI, or the like. If there are examples of this in your shop, follow them.
Queries are passed to the handler via the ADDRESS command. Assume that you executed the following to establish the environment:
then you would execute a query by:
address sql "SELECT FOO FROM BAR WHERE NOTARY="SOJAC"
and the values returned (if any) would be in the stem foo.. Other interfaces will have different means of handling queries and returning results.
A return code of -3 from ADDRESS is diagnostic that your attempt to create the environment failed. Do not bother to tell us that everything went marvelously and that gremlins somehow trashed the environment table.
If you encounter specific problems, you may discuss them with us. Posting nothing more than "My exec/query didn't work!" will lead to nothing more than a response of "Too bad, so sad". Refusal to give the information we ask for to diagnose the problem will result in our ignoring you. Demands that we give you all the code needed to perform function X will result in replies of the sort: "I charge USD n/day or fraction thereof to produce working, tested, and robust code; PayPal me the money and I'll e-mail the code". Be aware that n will likely be on the close order of 1,000. If this seems outrageous, remember that it is presumably your job on the line, not ours. Talk is cheap, but whiskey costs money.