IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX-DB2 Connectivity


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
balar

New User


Joined: 20 Dec 2006
Posts: 4
Location: US

PostPosted: Thu Dec 21, 2006 1:49 am
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Dec 21, 2006 2:38 am
Reply with quote

quick look
Code:
ADDRESS DSNREXX "CONNECT" 'DB2#'                                       
???
Back to top
View user's profile Send private message
balar

New User


Joined: 20 Dec 2006
Posts: 4
Location: US

PostPosted: Thu Dec 21, 2006 2:48 am
Reply with quote

Hi PeD,

I changed the code & tried again. But still i am getting the same error.

Thanks
Bala
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Dec 21, 2006 2:56 am
Reply with quote

Another try?
Code:
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX','DB2#.DB2.DSNLOAD')   
   
remove double quotes
?
Back to top
View user's profile Send private message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Thu Dec 21, 2006 3:47 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Dec 21, 2006 4:28 pm
Reply with quote

I guess that DB2# was the SSID icon_exclaim.gif
Back to top
View user's profile Send private message
balar

New User


Joined: 20 Dec 2006
Posts: 4
Location: US

PostPosted: Thu Dec 21, 2006 8:43 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Dec 21, 2006 11:12 pm
Reply with quote

Did you try my last correction or avaneendra_linga sample?
Back to top
View user's profile Send private message
balar

New User


Joined: 20 Dec 2006
Posts: 4
Location: US

PostPosted: Fri Dec 22, 2006 12:49 am
Reply with quote

Hi PeD,

I tried with that corrections. But it didn't work for me.

Thanks
Bala
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Fri Dec 22, 2006 1:49 am
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Fri Dec 22, 2006 1:51 am
Reply with quote

More : can you show the trace of your last execution?
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Dec 22, 2006 8:57 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top