plsql 귀속 삭제 또는 업데이트 실현

2041 단어
 --================================================ 
  PROCEDURE DEL_FUNCTION(P_ID INTEGER) IS
  BEGIN
    UPDATE EX_SYS_FUNCTION A SET A.YXBZ = 0 WHERE A.ID = P_ID;
    DEL_CHILDREN_FUNCTION(P_ID);
    -- 
  EXCEPTION
    WHEN OTHERS THEN
      ROLLBACK;
  END;

  --================================================ 
  PROCEDURE DEL_CHILDREN_FUNCTION(FUNCTION_ID INTEGER) IS
    IDCOUNT INTEGER;
  BEGIN
    FOR ITEM IN (SELECT ID
                   FROM EX_SYS_FUNCTION
                  WHERE PARENT_ID = FUNCTION_ID) LOOP
      SELECT COUNT(*)
        INTO IDCOUNT
        FROM EX_SYS_FUNCTION
       WHERE PARENT_ID = ITEM.ID;
      IF IDCOUNT > 0 THEN
        DEL_FUNCTION(ITEM.ID);
      END IF;
      IF IDCOUNT = 0 THEN
        UPDATE EX_SYS_FUNCTION A SET A.YXBZ = 0 WHERE ID = ITEM.ID;
      END IF;
    END LOOP;
    COMMIT;
  END;

좋은 웹페이지 즐겨찾기