USING RAISE_APPLICATION_ERROR ALSO GIVES ERROR ORA-06512 AND POSSIBLY ORA-04088 (Doc ID 1005760.6)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version 9.2.0.8 and later
Information in this document applies to any platform.
***Checked for relevance on 22-Nov-2013***


Symptoms

Using the RAISE_APPLICATION_ERROR to generate user-defined errors numbers and text does return the user defined errors but also includes additional error codes like ORA-06512 for stored procedures and error ORA-04088 for triggers.

The following illustrates a Stored Procedure that defines a user-defined error.

create or replace procedure test_raise as
begin
raise_application_error(-20011,'Raising Error');
end;
/

exec test_raise


Executing the above procedure does raise the application error but also returns the ORA-06512 error.

Sample Output


begin test_raise; end;
*
ERROR at line 1:
ORA-20011: Raising Error
ORA-06512: at "TESTCASE.TEST_RAISE", line 3
ORA-06512: at line 1


The following illustrates a Trigger that defines a user-defined error.

drop table t1;

create table t1 (c1 date);

create or replace trigger t1_trig before insert on t1 for each row
begin
if :new.c1 > sysdate then
raise_application_error(-20001,'Date entered must not be in the future.');
end if;
end;
/

insert into t1 values (sysdate+1);


Sample Output

insert into t1 values (sysdate+1)
*
ERROR at line 1:
ORA-20001: Date entered must not be in the future.
ORA-06512: at "TESTCASE.T1_TRIG", line 4
ORA-04088: error during execution of trigger 'TESTCASE.T1_TRIG'

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms