View previous topic :: View next topic
|
Author |
Message |
balar
New User
Joined: 20 Dec 2006 Posts: 4 Location: US
|
|
|
|
Hi,
Below REXX program is coded to talk to DB2. But i am facing some problem. Can you please help me out to resolve the problem?
Program:
Code: |
/* REXX */
ADDRESS ISPEXEC "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNLOAD')"
ADDRESS ISPEXEC "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNEXIT')"
SUBCOM DSNREXX
IF RC THEN
DO
S_RC = "RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')"
END
ADDRESS DSNREXX "CONNECT" DB2#
QUERY= "<<< query is here >>>>"
ADDRESS DSNREXX 'EXECSQL PREPARE S1 FROM :QUERY'
ADDRESS DSNREXX 'EXECSQL DECLARE C1 CURSOR FOR S1'
ADDRESS DSNREXX 'EXECSQL OPEN C1'
ADDRESS DSNREXX 'EXECSQL FETCH C1 INTO :NAME'
IF SQLCODE = 0 THEN
DO
SAY 'NAME : ' NAME
END
ELSE
SAY 'DB2 ERROR'
ADDRESS DSNREXX "DISCONNECT"
|
Error:
Code: |
4 *-* ADDRESS ISPEXEC "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNLOAD')"
>L> "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNLOAD')"
5 *-* ADDRESS ISPEXEC "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNEXIT')"
>L> "LIBDEF ISPLLIB DATASET ID('DB2#.DB2.DSNEXIT')"
6 *-* SUBCOM DSNREXX
>L> "SUBCOM"
>L> "DSNREXX"
>O> "SUBCOM DSNREXX"
+++ RC(1) +++
7 *-* IF RC
>V> "1"
*-* THEN
8 *-* DO
9 *-* S_RC = "RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')"
>L> "RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')"
10 *-* END
11 *-* ADDRESS DSNREXX "CONNECT" DB2#
>L> "CONNECT"
>L> "DB2#"
>O> "CONNECT DB2#"
+++ RC(-3) +++
12 *-* QUERY= "<<<< query is here >>>>"
13 *-* ADDRESS DSNREXX 'EXECSQL PREPARE S1 FROM :QUERY'
>L> "EXECSQL PREPARE S1 FROM :QUERY"
+++ RC(-3) +++
14 *-* ADDRESS DSNREXX 'EXECSQL DECLARE C1 CURSOR FOR S1'
>L> "EXECSQL DECLARE C1 CURSOR FOR S1"
+++ RC(-3) +++
15 *-* ADDRESS DSNREXX 'EXECSQL OPEN C1'
>L> "EXECSQL OPEN C1"
+++ RC(-3) +++
16 *-* ADDRESS DSNREXX 'EXECSQL FETCH C1 INTO :NAME'
>L> "EXECSQL FETCH C1 INTO :NAME"
+++ RC(-3) +++
17 *-* IF SQLCODE = 0
>L> "SQLCODE"
>L> "0"
>O> "0"
21 *-* ELSE
22 *-* SAY 'DB2 ERROR'
>L> "DB2 ERROR"
DB2 ERROR
23 *-* ADDRESS DSNREXX "DISCONNECT"
>L> "DISCONNECT"
+++ RC(-3) +++
***
|
Bala |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
quick look
Code: |
ADDRESS DSNREXX "CONNECT" 'DB2#'
|
??? |
|
Back to top |
|
|
balar
New User
Joined: 20 Dec 2006 Posts: 4 Location: US
|
|
|
|
Hi PeD,
I changed the code & tried again. But still i am getting the same error.
Thanks
Bala |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Another try?
Code: |
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')
|
remove double quotes
? |
|
Back to top |
|
|
avaneendra_linga
New User
Joined: 13 Dec 2006 Posts: 73 Location: Hyderabad
|
|
|
|
HI,
IN CONNECTION U NEED TO SPECIFY THE SUBSYSTEM ID NOT DB2
LIKE
SSID='DB02'
ADDRESS DSNREXX "CONNECT" SSID
I HOPE THIS SAMPLE CODE WILL HELPFUL TO U.
'SUBCOM DSNREXX'
IF RC\=0 THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX
ADDRESS DSNREXX "CONNECT" SSID
INSQLDA.SQLD = 2
INSQLDA.1.SQLTYPE = 453
INSQLDA.1.SQLLEN = 10
INSQLDA.1.SQLDATA = CMTYPE
INSQLDA.1.SQLIND = 0
INSQLDA.2.SQLTYPE = 453
INSQLDA.2.SQLLEN = 10
INSQLDA.2.SQLDATA = PATH
INSQLDA.2.SQLIND = 0
SQLSTMT=,
"SELECT LIBRARY",
"FROM LIBRARIES",
"WHERE TYPE=? AND PATH=?"
'EXECSQL DECLARE C1 CURSOR FOR S1'
IF SQLCODE < 0 THEN CALL SQLCA
'EXECSQL PREPARE S1 INTO :OUTSQLDA FROM :SQLSTMT'
IF SQLCODE < 0 THEN CALL SQLCA
'EXECSQL OPEN C1 USING DESCRIPTOR :INSQLDA'
IF SQLCODE < 0 THEN CALL SQLCA
'EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA'
SELECT
WHEN SQLCODE < 0 THEN DO
CALL SQLCA
END
WHEN SQLCODE = 100 THEN DO
SAY' COMPONENT IS NOT FOUND IN THE DATA TABLE'
CALL ABNORMALEND
END
WHEN SQLCODE = 0 THEN DO
TABLDSN=STRIP(OUTSQLDA.1.SQLDATA)
END
OTHERWISE NOP
END
'EXECSQL CLOSE C1'
ADDRESS DSNREXX "DISCONNECT"
IF SQLCODE < 0 THEN DO
CALL SQLCA
END
S_RC = RXSUBCOM('DELETE','DSNREXX','DSNREXX') |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
I guess that DB2# was the SSID |
|
Back to top |
|
|
balar
New User
Joined: 20 Dec 2006 Posts: 4 Location: US
|
|
|
|
Hi,
DB2# is the subsystem id. still hanging on with the same problem(RC(3) for db2 connection). Not able to connect to DB2.
Hope somebody can ehlp me out.
Thanks
Bala |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Did you try my last correction or avaneendra_linga sample? |
|
Back to top |
|
|
balar
New User
Joined: 20 Dec 2006 Posts: 4 Location: US
|
|
|
|
Hi PeD,
I tried with that corrections. But it didn't work for me.
Thanks
Bala |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
I just execute your code and it is not working with
Code: |
S_RC = "RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')"
|
>>> RC(-3)
but it is working with
Code: |
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')
|
Another question : can you execute like this ?
Code: |
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
|
Last suggestion : be stubborn, try, modify one thing, retry, undo, remodify, retry..... and again and again
Cheers
Pierre |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
More : can you show the trace of your last execution? |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
PeD has given you the correct answer to your problem, and as he stated
you do not need to include the loadlib in your command.
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX') |
|
Back to top |
|
|
|