Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 in Rexx

Status
Not open for further replies.

rajesh082

Programmer
Dec 18, 2007
38
DK
I am trying to run some SQL's using Rexx. I want to run some dynamic SQL's in a Rexx code. I do know how to run Static SQL's using DSNREXX.

Can somebody tell me how to run Dynamic SQL's using DSNREXX.

Code:
call rxsubcom 'add', 'ostsql', 'rxtasql2'       
say 'RXSUBCOM RC='rc 'REASON='reason            
if rc > 4 then do                               
  say 'RXSUBCOM failed. DB201 Terminating.'     
  exit                                          
end                                             


if db2info('defaults') <> 0 then do    
  say 'DB2INFO call failed. RC='rc     
  exit rc                              
end                                    

 call dsnali 'open', £rxtdb2_ssid, 'rxtcs'      
 say 'DSNALI OPEN RC='rc 'REASON='reason        
 if rc <> 0 then do                             
   say 'OPEN FAILED. DB201 Terminating.'        
   exit                                         
 end                                            

address ostsql "options sqlca sqlda" 

sqlcmd = arg(1)                                          
address ostsql                                           
s = sysvar('syscpu')                                     
sqlcmd                                                   
e = sysvar('syscpu')                                     
say 'ADDRESS SQL RC='rc 'REASON='reason 'TOTAL CPU='e-s  
if rc <> 0 then                                          
  exit

The problem here is that I get a RC=12 REASON=00F30006 for the DSNALI open, & a RC of -3 for options sqlca sqlda. The £rxtdb2_ssid is equal to DSN1 which is not a DB2 SYSID in my shop. If I do change it to DQA0 (The DB2 subsystem where i want to run the SQL's), the code changes to DSNALI OPEN RC=8 REASON=00F30034.

Any pointers would be real help for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top