DB2 queries using rexx.

Time Sharing Option, Interactive System Productivity Facility and REstructured eXtended eXecutor

Moderator: mickeydusaor

Post Reply
Om Shah
New Member
Posts: 5
Joined: Sun Aug 03, 2014 8:20 pm

DB2 queries using rexx.

Post by Om Shah »

HI,

Can we code DB2 queries using rexx? How can we do that? Can you please provide an example and or share some links to learn them.
User avatar
Akatsukami
Global Moderator
Global Moderator
Posts: 122
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL
Contact:

Re: DB2 queries using rexx.

Post by Akatsukami »

Om Shah wrote:HI,Can we code DB2 queries using rexx?
Certainly.
How can we do that?
By establishing a DB2 environment via RXSUBCOM (most shops use the IBM-supplied DSNREXX command processor; mine, however, uses Open Software's RXTASQL). Then, you can use embedded or dynamic SQL as with any other language.
Can you please provide an example and or share some links to learn them.
See here.
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: DB2 queries using rexx.

Post by nicc »

Please do your reserch BEFORE posting. Many examples and references over the Internet and, as Akatsukami has pointed out, in the DB2 manuals themselves - which you, obviously, did not consult.
Regards
Nic
Om Shah
New Member
Posts: 5
Joined: Sun Aug 03, 2014 8:20 pm

Re: DB2 queries using rexx.

Post by Om Shah »

Thanks Akatsukami. I have searched more and got this sample program which was very useful to me:

Code: Select all

"SUBCOM DSNREXX"                                                        
IF RC=0 THEN                                                            
   SAY 'DSNREXX  IS AVAILABLE'                                          
ELSE                                                                    
   DO                                                                    
    SAY 'DSNREXX  IS NOT AVAILABLE'                                      
    SAY 'SUBCOM RC :' RC                                                
   END                                                                  
                                                                        
IF RC THEN                                                              
   DO                                                                    
     S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')                          
     SAY 'ADDING DSNREXX....................'                            
     PULL X                                                              
   END                                                                  
                                                                        
SQLSTMT = "SELECT COUNT(*)  FROM DB0*****.****** "                  
ADDRESS DSNREXX                                                          
"CONNECT DB2E"                                                          
                                                                        
"EXECSQL DECLARE C1 CURSOR FOR S1"                                      
                                                                        
"EXECSQL PREPARE S1 INTO :OUTSQLDA FROM :SQLSTMT"                        
                                                                        
"EXECSQL OPEN C1"                                                        
                                                                        
"EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA"                            
                                                                        
        DO I = 1 TO OUTSQLDA.SQLD                                        
           LINE = OUTSQLDA.I.SQLDATA                                    
        END                                                              
                                                                        
SAY LINE                                                                
                                                                        
"EXECSQL EXECUTE S1 USING DESCRIPTOR :OUTSQLDA"
This link http://publib.boulder.ibm.com/cgi-bin/b ... 0209162045 had been very useful too.
Om Shah
New Member
Posts: 5
Joined: Sun Aug 03, 2014 8:20 pm

Re: DB2 queries using rexx.

Post by Om Shah »

This pdf was also very useful:
DB2 and the Joy of Rexx.pdf
You do not have the required permissions to view the files attached to this post.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “TSO, ISPF & REXX (Do you still do CLIST?!).”