Hi Gurus,
I have 3 procedures below.
Proc1 and Proc2 are fine, when count > 0, user is getting exception.
I have confusion in Proc3, where I am raising exception but procedure is silently ending successfully.
I was under the impression that it should have raised exception to user, why control is going to when_others_then in this case and procedure is successful?
Should we not use raise_application_error along with when others then ?
CREATE OR REPLACE PROCEDURE TEST_PROC1
AS
V_COUNT NUMBER := 1;
E_EXCEPTION EXCEPTION ;
BEGIN
IF V_COUNT >0 THEN
RAISE E_EXCEPTION;
END IF;
EXCEPTION
WHEN E_EXCEPTION THEN
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error Occured');
END;
CREATE OR REPLACE PROCEDURE TEST_PROC2
AS
V_COUNT NUMBER := 1;
BEGIN
IF V_COUNT >0 THEN
RAISE_APPLICATION_ERROR(-20102,'Difference in VW_CHECK_NON_ZERO_BAL_MTH.Please check');
END IF;
END;
CREATE OR REPLACE PROCEDURE TEST_PROC3
AS
V_COUNT NUMBER := 1;
BEGIN
IF V_COUNT >0 THEN
RAISE_APPLICATION_ERROR(-20102,'Difference in VW_CHECK_NON_ZERO_BAL_MTH.Please check');
END IF;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error Occured');
END;