Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1079163
  • 博文数量: 106
  • 博客积分: 9093
  • 博客等级: 中将
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 17:22
文章分类

全部博文(106)

文章存档

2014年(1)

2012年(29)

2011年(32)

2010年(20)

2008年(24)

分类:

2010-03-24 15:10:23

一条一条读取全部符合记录
            DS                                                              
     I                                        1 132 D#DATA                        
     I                                      133 135 D#KEY                         
            DS                                                              
     I                                        1   4 W#BLK                         
     I                                        5   7 W#KEY                         
     I                                        8  20 W#DTA                         
     I                                       21 132 W#SPC                         
     **                                                                           
     C                     MOVEL'111'     ##KEY   3                               
     **                                                                           
     C/EXEC SQL                                                                   
     C+ DECLARE C1 CURSOR FOR                                                     
     C+ SELECT SPLF,SUBSTR(SPLF,5,3) AS KEY                                       
     C+ FROM PTRLIB/SPLF                                                          
     C+ WHERE SUBSTR(SPLF,5,3) = :##KEY                                           
     C+ ORDER BY KEY                                                              
     C/END-EXEC                                                                   
     **          
     C/EXEC SQL                                                
     C+ OPEN C1       
 
                                          
     C/END-EXEC                                                
     **                                                        
     C           LABF      TAG      
     C                     MOVEL*BLANK                                  
     C/EXEC SQL                                                
     C+ FETCH C1 INTO :D@DTA                                   
     C/END-EXEC                                                
     **                                                        
     C           SQLCOD    IFEQ *ZERO                          
     C                     MOVELD#DATA                    
     C           W#KEY     DSPLY                               
     C           W#DTA     DSPLY                               
     C                     GOTO LABF                           
     C                     ENDIF                               
     **                                                         
     C/EXEC SQL                                                   
     C+ CLOSE C1                                                  
     C/END-EXEC                                         
     **                                                 
     C                     SETON                     LR 
     C                     RETRN                        
 
读取指定条数的符合记录
            DS                         10                                 
     I                                        1 132 D#DATA                      
     I                                      133 135 D#KEY                       
            DS                                                            
     I                                        1   4 W#BLK                       
     I                                        5   7 W#KEY                       
     I                                        8  20 W#DTA                       
     I                                       21 132 W#SPC                       
     **                                                                         
     C                     MOVEL'111'     ##KEY   3                             
     **                                                                         
     C/EXEC SQL                                                                 
     C+ DECLARE C1 CURSOR FOR                                                   
     C+ SELECT SPLF,SUBSTR(SPLF,5,3) AS KEY                                     
     C+ FROM PTRLIB/SPLF                                                        
     C+ WHERE SUBSTR(SPLF,5,3) = :##KEY                                         
     C+ ORDER BY KEY                                                            
     C/END-EXEC                                                                 
     **                                                                         
     C/EXEC SQL                                                        
     C+ OPEN C1                                                        
     C/END-EXEC                                                        
     **                                                                
     C           LABF      TAG                                         
     C/EXEC SQL                                                        
     C+ FETCH C1 FOR 10 ROWS INTO :D@DTA                               
     C/END-EXEC                                                        
     **                                                                
     C           SQLCOD    IFEQ *ZERO                                  
     C           1         DO   10        #I      20                   
     C           #I        OCUR                                   
     C                     MOVELD#DATA                            
     C           W#KEY     DSPLY                                       
     C           W#DTA     DSPLY                                       
     C                     MOVEL*BLANK                            
     C                     ENDDO                                       
     C                     GOTO LABF                                   
     C                     ENDIF                                       
     **                                                                
     C/EXEC SQL                                                        
     C+ CLOSE C1                                                       
     C/END-EXEC                                                        
     **                                                                
     C                     SETON                     LR                
     C                     RETRN                                       
阅读(2220) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~