1. 程式人生 > >db2中的迴圈語句

db2中的迴圈語句

DECLARE CUR_FEESET CURSOR WITH RETURN TO CALLER FOR (
              SELECT
                     --
              FROM 表
              WHERE 條件
              );
       OPEN CUR_FEESET;--得到遊標
       --得到遊標記錄數
       SELECT
       count(CIF_CSTNO)
       into v_count
       FROM CB_CSTINF A ,CB_CSTBSNINF B
       WHERE A.CIF_STT<>'3' AND A.CIF_CSTNO = B.CBI_CSTNO ;   --
       FETCH CUR_FEESET INTO V_CSTNO,V_FEECODE,V_CSTLEVEL,V_FEEMODE;--
       WHILE V_COUNT>0 DO
     ……..
         FETCH CUR_FEESET INTO V_CSTNO,V_FEECODE,V_CSTLEVEL,V_FEEMODE;--
       END WHILE; --