Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REXX-DB2 Connectivity

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: REXX-DB2 Connectivity
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: 456
Location: Belgium

PostPosted: Thu Dec 21, 2006 2:38 am    Post subject:
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    Post subject: Re: REXX-DB2 Connectivity
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: 456
Location: Belgium

PostPosted: Thu Dec 21, 2006 2:56 am    Post subject:
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    Post subject: Re: REXX-DB2 Connectivity
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: 456
Location: Belgium

PostPosted: Thu Dec 21, 2006 4:28 pm    Post subject:
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    Post subject: Re: REXX-DB2 Connectivity
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: 456
Location: Belgium

PostPosted: Thu Dec 21, 2006 11:12 pm    Post subject:
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    Post subject: Re: REXX-DB2 Connectivity
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: 456
Location: Belgium

PostPosted: Fri Dec 22, 2006 1:49 am    Post subject:
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: 456
Location: Belgium

PostPosted: Fri Dec 22, 2006 1:51 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us