• 操作vsam用sequential访问模式REWRITE数据


    因为在SEQUENTIAL访问模式下,只有I/O方式打开文件才能进行REWRITE操作,所以以下文件均用I/O方式打开。 

    FILE-CONTROL.                      
             SELECT VFILE ASSIGN TO VF  
             ORGANIZATION IS INDEXED    
             ACCESS MODE IS SEQUENTIAL  
             RECORD KEY IS VID          
             FILE STATUS IS FS1.        
     DATA DIVISION.                     
     FILE SECTION.                      
     FD VFILE.                          
     01 VREC.                           
        05 VID PIC X(4).                
        05 VINFO PIC X(76).             
     WORKING-STORAGE SECTION.           
     01 FS1 PIC 99.                     
     01 REC PIC X(80).                  
     01 FLAG PIC X.                       

    PROCEDURE DIVISION.                                    
             OPEN I-O VFILE.                                
             DISPLAY FS1.                                   
             MOVE 0444 TO VID.                              
             MOVE '0444D02APPLE' TO REC.                    
             START VFILE KEY IS = VID.                      
             READ VFILE  
             END-READ.                                      
             REWRITE VREC FROM REC                          
             END-REWRITE.                                   
             DISPLAY FS1.                                   
             IF FS1 = 00                                    
             THEN                                           
                  DISPLAY 'THE RECORD IS ', VREC            
             END-IF.                                        
             CLOSE VFILE.                                   
             STOP RUN.        

    总结

    SEQUENTIAL三步曲:

    1.start

    2.read(因为rewrite之前必须read,不然就返回码43,而要想read指定记录就需要先start定位到指定的位置上,所以……)

    3.rewrite……from……(from也是必须的,这是逻辑上的需要,相信聪明的童靴都会懂的) 或者 delete……                              

  • 相关阅读:
    AVL平衡二叉树
    算法集锦(二)
    算法集锦(一)
    选择问题 and 字谜游戏问题
    TF-IDF与余弦相似性的应用
    一致性哈希算法
    Cache缓存
    布隆过滤器
    信号
    设置用户ID和设置组ID
  • 原文地址:https://www.cnblogs.com/mooncher/p/2746442.html
Copyright © 2020-2023  润新知