DYNAMIC SQL statement (1) - 完整非SELECT语句

 01  WORK-FIELDS.                                 
    05 TABLE-NAME     PIC X(18).                 
    05 CUSTNO         PIC X(6).                  
    05 DEL-STMT.                                 
       49 DEL-STMT-LEN  PIC S9(4) COMP VALUE +320.
       49 DEL-STMT-TEXT PIC X(230).             
B010-PROCESS-ROW.                 
    PERFORM B110-ACCEPT-TABLE-NAME.
    IF NOT EOF-ACCEPT             
       PERFORM B120-ACCEPT-CUSTNO 
    END-IF.                       
    IF NOT EOF-ACCEPT             
       PERFORM B210-DELETE-CUST   
    END-IF.                       

(Need to check the whether to the end of ACCEPT after every accept execution)

 B210-DELETE-CUST.                          
     MOVE SPACE TO DEL-STMT-TEXT.           
     STRING 'DELETE FROM TOUGH.' TABLE-NAME 
            'WHERE INVNO= ''' INVNO ''''    
            DELIMITED BY SIZE               
            INTO DEL-STMT-TEXT.             
     DISPLAY 'SQL: ' DEL-STMT-TEXT.         
     EXEC SQL                               
       EXECUTE IMMEDIATE :DEL-STMT          
     END-EXEC.         

(1)                    
     EXEC SQL                               
       COMMIT                               
     END-EXEC.
                                                

If the program stop run without commit after execution of the above sql statment, the sqlcode=00000010M.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值