Tuesday, 16 July 2019

Exception: ORA-0000: normal, successful

Exception: ORA-0000: normal, successful

Cause: The message itself it is showing that process completed normally. So this message will display when we use SQLERRM to display error message outside side exception block.

Example 1:

begin
dbms_output.put_line(SQLERRM);
end;

Example 2:

DECLARE
    var              NUMBER;
    v_boolean        BOOLEAN;
    test_exception   EXCEPTION;
    v_msg            VARCHAR2(1000);

    FUNCTION p_test (p_num number, p_message OUT varchar2) return boolean
    IS
    BEGIN
        if p_num is null then
        p_message := 'p_num cannot be null';
        return FALSE;
        end if;
    EXCEPTION
        WHEN OTHERS
        THEN
           DBMS_OUTPUT.put_line (SQLERRM);
    END p_test;
BEGIN
    var := NULL;

    if not p_test(var, v_msg) then
 
    dbms_output.put_line(SQLERRM);
    dbms_output.put_line(v_msg);
 
    end if; 
 
EXCEPTION
    WHEN test_exception
    THEN     
       NULL;
END;

Output:

ORA-0000: normal, successful completion
p_num cannot be null