View previous topic :: View next topic |
Author |
Message |
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Mon Nov 24, 2008 4:43 am Post subject: Insert records into table using REXX |
|
|
Hi,
Can any one please guide me the way to insert data into table using rexx?
All I have did is built a job using rexx and submitted but I need a rexx instead building jcl.
Thanks,
Kingo _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
superk Advanced
Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Mon Nov 24, 2008 5:51 am Post subject: |
|
|
Your post is in the TSO and ISPF forum, so I'd presume that you're referring to an ISPF Table. Is that a correct assumption? |
|
Back to top |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Mon Nov 24, 2008 5:57 am Post subject: |
|
|
Superk,
Its into a db2 table..
I had built a job using rexx and thats working fine but I need a pure rexx to do the same process.
Regds,
Kingo _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Nov 24, 2008 3:17 pm Post subject: |
|
|
Hi Kingo
You have a working rexx program that does what you want but you run it in batch not foreground? Just execute it in foreground.
===> TSO myrexx
If this is not what you mean then you will need to give more info. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Mon Nov 24, 2008 11:23 pm Post subject: |
|
|
Yes Nic I got to give more info
I am building a panel where you feed in some data and when hit enter it throws that data into table..
At backhand I am using rexx which builds a jcl and submits but what all I want to do is instead of using a JCL I need to use just rexx which just process data and does an insert to the table.
So I dont need a rexx which does an insert and process but instead I want rexx itself to insert the data.
Regds,
Kingo _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Tue Nov 25, 2008 11:29 am Post subject: |
|
|
To get connected to DB2 via REXX: (SSID is the subsystem ID)
"SUBCOM DSNREXX"
IF RC THEN
RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT" SSID
Build your insert statement in the REXX program using variables from your panel.
To execute an Insert statement from REXX:
ADDRESS DSNREXX
"EXECSQL " INSERT_STATEMENT_HERE
<< Check your SQLCODE!!! >>
To disconnect from DB2 via REXX:
"SUBCOM DSNREXX"
IF RC = 0 THEN
RC = RXSUBCOM("DELETE","DSNREXX","DSNREXX") |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Tue Nov 25, 2008 4:21 pm Post subject: |
|
|
These are my notes from when I was playing with Rexx/DB2
From the manual 'DB2 UDB for zOS V7 Application Programming and SQL Guide'
these are the commands to run access DB2 from Rexx:
Check if the environment is available
'SUBCOM DSNREXX'
If not - make it available
'If rc Then s_rc = RXSUBCOM('ADD','DSNREXX','DSNREXX')
The address environment DSNREXX is available
Address DSNREXX
You have to chat up the DB2 subsystem (ssid)
'CONNECT 'ssid
And then you have to give DB2 some work
'EXECSQL' 'sqlstmt' or
'EXECSQL' rexxvar
However, to use host variables you need to PREPARE the statment. See the
file HOSTVAR below.
And, finally, wave goodbye
'DISCONNECT'
and remove the environment (if it was not available beforehand!)
s_rc = RXSUBCOM('DELETE','DSNREXX','DSNREXX')
HOSTVAR....
The SQLDA is structured as follows:
OUTSQLDA.SQLD - number of variables returned
OUTSQLDA.1.SQLDATA - first variable returned
:
OUTSQLDA.sqld.SQLDATA - last variable returned
Example 1 demonstrates retrieval of a row from a table.
GENERAL NOTE:
1 - Table name even if fully qualified should be unquoted
2 - Do not terminate the SQL statement with a semi-colon (
Example 1 - SELECT
------------------
This is the SQL statement:
sqlstmt = ,
"SELECT",
"r_nsc, r_account, r_limitamt, r_priority",
"FROM xxx.yyy_zzzz_aaaa", Note 1, above.
"WHERE r_nsc = '999999'" Note 2, above.
You must use prepared statement S1 with cursor C1
"EXECSQL DECLARE C1 CURSOR FOR S1"
"EXECSQL PREPARE S1 INTO :outsqlda FROM :sqlstmt"
"EXECSQL OPEN C1"
Note: EXECSQL returns rc=1 (SQL warning issued) but SQLCODE is 0 so
check SQLCODE rather than rc
"EXECSQL FETCH C1 USING DESCRIPTOR :outsqlda"
"EXECSQL CLOSE C1"
If IndPhone < 0 /* null */
Then Say 'Phone number for Haas is null.' _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Thu Nov 27, 2008 9:57 am Post subject: |
|
|
Thanks Jim and nic..
I had done those changes accordingly and it worked fine
Regds,
Kingo _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
|
|