Query regarding REXX DSN code.



IBM's flagship relational database management system

Query regarding REXX DSN code.

Postby Viswanathchandru » Mon Jan 24, 2011 9:38 am

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.
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Query regarding REXX DSN code.

Postby NicC » Mon Jan 24, 2011 10:45 am

So, what is your error? Have you checked the previous thread on this topic?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Query regarding REXX DSN code.

Postby Viswanathchandru » Mon Jan 24, 2011 10:57 am

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
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Query regarding REXX DSN code.

Postby NicC » Mon Jan 24, 2011 11:06 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Query regarding REXX DSN code.

Postby Viswanathchandru » Mon Jan 24, 2011 11:15 am

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
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Query regarding REXX DSN code.

Postby NicC » Mon Jan 24, 2011 11:29 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Query regarding REXX DSN code.

Postby Viswanathchandru » Mon Jan 24, 2011 11:47 am

Thanks Nicc for your support and replies.


Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Query regarding REXX DSN code.

Postby NicC » Mon Jan 24, 2011 11:23 pm

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
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Query regarding REXX DSN code.

Postby Akatsukami » Tue Jan 25, 2011 2:13 am

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Query regarding REXX DSN code.

Postby Viswanathchandru » Wed Jan 26, 2011 5:40 pm

Thanks Nicc and Akatsukami for your time and replies.
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post