oracle 存储过程2

DROP PROCEDURE MRR.delete_risk_assessment;

CREATE OR REPLACE PROCEDURE MRR.delete_risk_assessment (
    id IN NUMERIC
) IS
BEGIN
        DELETE MRR.riskassessmentvalue
         WHERE risktypedetail_id IN
         (
               SELECT MRR.risktypedetail_id FROM risktypedetail
                WHERE riskassessment_id = id
          );
       
        SAVEPOINT point1;    
        
        DELETE MRR.risktypedetail
         WHERE riskassessment_id = id;
        
        SAVEPOINT point2;
       
        DELETE MRR.riskassessment
         WHERE riskassessment_id = id;
        
        EXCEPTION
         WHEN OTHERS THEN   ---若出现异常 执行回滚
              ROLLBACK TO SAVEPOINT point1;
END;
/

GRANT EXECUTE ON MRR.delete_risk_assessment TO DMM_KCMRLRSK_ROLE;
/

你可能感兴趣的:(oracle,存储过程,职场,oracl,休闲)