| Himesh CICS Forum Moderator
 
  
 
 Joined: 20 Dec 2002
 Posts: 80
 Topics: 21
 Location: Chicago
 
 | 
			
				|  Posted: Fri Dec 27, 2002 1:23 am    Post subject: Simple REXX for SQL select |   |  
				| 
 |  
				| Heres a simple REXX to view results of an SQL (select), "online". 
 Pls change the 'XXXX.RUNLIB.LOAD' (for DSNTEP2) and 'SUBS' accordingly.
 
 [code:1:4249b097b1]
 /* Rexx - SQL SELECT from a Rexx program    */
 /* #inp  - dataset name for output          */
 /* #inp  - SQL                              */
 /* #out  - output is stored in the DS       */
 
 Mainline:
 call Initialize
 call SQL_SELECT
 call Determine_Results
 if SResult = 'SUCCESS' then call Display_Success
 else call Display_Errors
 call Terminate
 exit (0)
 
 Initialize:
 say '  ********  Online SQL browser********'
 say 'Enter the DS name for output(fully qualified name!)'
 pull dsname
 
 "ALLOC da('"dsname"') f(file) TRACK LRECL(133) BLKSIZE(133)
 space(50,20) MOD"
 address TSO
 msgs = msg(off)
 "FREE  F(SYSIN, SYSPRINT)"
 msgs = msg(on)
 "ALLOC F(SYSIN) SPACE(1,1) TRACK LRECL(80) RECFM(F) BLKSIZE(80) NEW"
 "NEWSTACK"
 
 i=0
 choice='Y'
 
 do until choice='N'
 if choice = 'Y'  then do
 if i=0 then
 say 'Please Enter SQL:'
 else
 say 'Enter additional clause(s):'
 pull sql1
 i=i+1
 sql.i=sql1
 end
 say 'Do u want to continue?(y/n)'
 Pull choice
 upper choice
 end
 do j=1 to i
 queue sql.j
 end
 
 "EXECIO * DISKW SYSIN ( FINIS"
 "DELSTACK"
 "ALLOC F(SYSPRINT) SPACE(1,1) TRACK LRECL(133) RECFM(F) BLKSIZE(133) NEW"
 return
 
 SQL_SELECT:
 /* Create a new stack and run DSN  */
 address TSO
 "NEWSTACK"
 
 queue "RUN PROGRAM (DSNTEP2) PLAN(DSNTEP31) LIBRARY('XXXX.RUNLIB.LOAD')"
 /* XXXX.RUNLIB.LOAD
 |  |