View previous topic :: View next topic
|
Author |
Message |
respondvignesh Currently Banned New User
Joined: 08 Sep 2009 Posts: 2 Location: Chennai
|
|
|
|
can we perform sql queries and access databases in rexx????? If so, let me know a simple program in rexx to perform sql queries. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Yes,
Google will give you lots of examples. Maybe the first port of call before posting here. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
I think, for an answer, we'd need to know what kind of database(s) and queries we're talking about. |
|
Back to top |
|
|
respondvignesh Currently Banned New User
Joined: 08 Sep 2009 Posts: 2 Location: Chennai
|
|
|
|
This is for SQL and DB2 |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
respondvignesh wrote: |
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:
Code: |
call rxsubcom("ADD",name,handler)
|
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:
Code: |
call rxsubcom("ADD","SQL","RXTASQL")
|
then you would execute a query by:
Code: |
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. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
|