Page 1 of 1

Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 9:38 am
by Viswanathchandru
Hi,
Good day!! I'm new to REXX programming. Trying to learn the basics. I ve a rexx code witch fetches records from the DB2 tables. But i don know where do i go wrong. Pls help me out. My code goes this way.

/* REXX */                                                         
SQLSTMT= "SELECT * FROM SYSIBM.SYSRESAUTH WHERE GRANTEE='XXXXXX'"
ADDRESS TSO "SUBCOM DSNREXX"                                       
IF RC = 0 THEN                                                     
    S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')                     
    ADDRESS DSNREXX "CONNECT DSN1"                                 
    IF SQLCODE ¬=0 THEN CALL SQLCA                                 
    ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"             
    IF SQLCODE ¬=0 THEN CALL SQLCA                                 
    ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT1"           
    IF SQLCODE ¬=0 THEN CALL SQLCA                                 
    ADDRESS DSNREXX "EXECSQL DESCRIBE S1 INTO :OUTSQLDA"           
    IF SQLCODE ¬=0 THEN CALL SQLCA                                 
ADDRESS DSNREXX "EXECSQL OPEN C1"                                 
    IF SQLCODE ¬=0 THEN CALL SQLCA         

           DO UNTIL(SQLCODE ¬=0)                               
 ADDRESS DSNREXX "EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA" 
             IF SQLCODE=0 THEN                                 
                DO                                             
                  DO I=1 TO OUTSQLDA.SQLD                       
                     SAY"> COLUMN NUMBER: " I                   
                     SAY" COLUMN NAME:"OUTSQLDA.I.SQLNAME"     
                     SAY" COLUMN TYPE:"OUTSQLDA.I.SQLTYPE"     
                  END                                           
                END                                             
           END                                                 
   RETURN                                                       
               SQLCA:                                           
                    SAY " SQLCODE:" SQLCODE                     
                    SAY " SQLSTATE:" SQLSTATE                   
                    SAY " SQLLERRMC:" SQLLERRMC                 
 EXIT                                       


Apologies if 'm wrong.

Regards,
Viswa.

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 10:45 am
by NicC
So, what is your error? Have you checked the previous thread on this topic?

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 10:57 am
by Viswanathchandru
Thank u nicc! for giving reply.. when i execute this i got "*-* ADDRESS DSNREXX "CONNECT DSN1"
+++ RC(-3) +++ " as i didnt get any sql return codes i'm not able to find where m going wrong. Please guide me. waiting for your reply..


Regards,
Viswa

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 11:06 am
by NicC
I suggest you look more closely at the manual and the other thread. You do NOT add rxsubcon if it is already there. Is DSN1 a variable or the actual sub-system id (ssid)?

RC = -3 means you got your command wrong.

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 11:15 am
by Viswanathchandru
Thanks again!! DSN1 is the subsystem id. Sorry to ask. How do i find whether i have RXSUBCOM already there or not? apologies if m wrong.

Regards
viswa

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 11:29 am
by NicC
I am not going to do your work for you: I have already told you to look at the manual (this one " DB2 Application Programming and SQL Guide") and look at the other thread. The other thread ended up with working code.

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 11:47 am
by Viswanathchandru
Thanks Nicc for your support and replies.


Regards,
Viswa

Re: Query regarding REXX DSN code.

PostPosted: Mon Jan 24, 2011 11:23 pm
by NicC
I have re-checked your syntax and it looks good so there are 2 possibilities:
1 - DSNREXX is not avaialble
2 - your DB2 system is not DSN1

Re: Query regarding REXX DSN code.

PostPosted: Tue Jan 25, 2011 2:13 am
by Akatsukami
A return code of -3 from ADDRESS means that the environment being addressed does not exist. Period. No other interpretation is possible.

As I have written elsewhere, SUBCOM is pretty much worthless. It checks that there is a row with the given name in the TSO environment table. It does not check if that row is valid. It is quite possible to get RC=0 from "SUBCOM FOO" and RC=-3 from "ADDRESS FOO". Discard the call to SUBCOM.

Re: Query regarding REXX DSN code.

PostPosted: Wed Jan 26, 2011 5:40 pm
by Viswanathchandru
Thanks Nicc and Akatsukami for your time and replies.