Raise Application Error
743195Jan 20 2010 — edited Jan 20 2010Hi,
If i see the syntax of RAISE_APPLICATION_ERROR its:
RAISE_APPLICATION_ERROR(error_number,error_message,[keep_errors]);
Where
error_number is between -20000 and -20999
error_message should be <512 characters and
keep_errors is an optional Bollean flag . If its TRUE, the new error is added to the list of errors already raised.
If FALSE, which is the default,the new error will replace the current list of errors.
I am not clear with [keep_errors] :
Doing this:
declare
v_errorcode varchar2(4000);
v_errormsg varchar2(1000);
v_temp varchar2(20);
begin
select 30 into v_temp from dual;
If v_temp > 20 THEN
RAISE_APPLICATION_ERROR(-20001,'Students are more',TRUE);
RAISE_APPLICATION_ERROR(-20002,'Students are less',TRUE);
END IF;
exception
when others then
v_errorcode := SQLCODE;
v_errormsg := SQLERRM;
DBMS_OUTPUT.PUT_LINE(v_errorcode);
DBMS_OUTPUT.PUT_LINE(v_errormsg);
end;
is giving me only first error i.e Students are more,-20001. Why not -20002 as keep_errors is true?
The code is just for testing purpose.
Anyone please clarrify the concept of keep_errors ? Any small example will be highly appreciated.
TIA
Regards,
Mohit