網路城邦
上一篇 回創作列表 下一篇   字體:
TIPTOP 一次鎖定多筆資料
2018/05/29 13:33:52瀏覽953|回應0|推薦0
LET g_sql=" SELECT oea01,oea02",

          "   FROM tw.oea_file",                       

          "  WHERE oea01 in (SO1-18030004,SO1-18030006,SO1-18030009,SO1-18050003) ",

          "  ORDER BY oea01  FOR UPDATE NOWAIT"


PREPARE test_m_rcds_lock_prep FROM g_sql

        IF STATUS THEN

           DISPLAY test_m_rcds_lock_prep:,STATUS

           EXIT PROGRAM

        END IF               


#DECLARE test_m_rcds_lock_cur CURSOR WITH HOLD FOR test_m_rcds_lock_prep  #SQL有FOR UPDATE -> Not Support WITH HOLD 

DECLARE test_m_rcds_lock_cur CURSOR FOR test_m_rcds_lock_prep

        IF STATUS THEN

           DISPLAY prepare test_m_rcds_lock_cur:,STATUS

           CLOSE test_m_rcds_lock_cur

           FREE test_m_rcds_lock_cur

           EXIT PROGRAM

        END IF 

                      

     BEGIN WORK  


     FOREACH test_m_rcds_lock_cur INTO l_oea.oea01,l_oea.oea02  #鎖住全部,Lock All Selected rcds

        IF STATUS THEN 

           DISPLAY FOREACH test_m_rcds_lock_cur:,STATUS       

           CONTINUE FOREACH 

        END IF 

        DISPLAY l_oea.oea01, / ,l_oea.oea02    

     END FOREACH


     CLOSE test_m_rcds_lock_cur  

     COMMIT/ROLLBACK WORK  #解開lock release at here

     FREE test_m_rcds_lock_cur
( 知識學習其他 )
回應 推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=shfm1969&aid=112187341