RAISE_APPLICATION_ERROR procdure defined in STANDARD package and it can only invoked from stored subprogram.This procedure is used to raise a error code and error message
RAISE_APPLICATION_ERROR(error_code, message [,{TRUE|FALSE}]);
If TRUE specified, PL/SQL put error_code on the top of the error stack otherwise error stack replaced with the error_code
CREATE PROCEDURE training_status ( l_training_id VARCHAR2(10)) IS
v_no_of_student NUMBER(3);
BEGIN
SELECT COUNT(1) INTO V_no_of_student
FROM training
WHERE training_id = l_training_id;
IF v_no_of_student >= 40 THEN --explicitly raise error
RAISE_APPLICATION_ERROR(-20000,'Training class full');
END IF;
END;
/
DECLARE
e_trainign_full EXCEPTION; --declare exception
PRAGMA EXCEPTION_INIT e_trainign_full(-20000,e_class_full);
BEGIN
training_status('ORACLE');
EXCEPTION
WHEN e_trainign_full THEN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQLERRM(-20000)));
END;
/
Result:
ORA-20000: Training Class full
Subscribe to:
Post Comments (Atom)
External Table
Oracle External Table External tables are defined as tables that do not resides in the database allows you to access data that is stor...
-
Table clustering is an optional technique of storing data. In table clustering, rows from one or more tables those are associated with ea...
-
Oracle PL/SQL block accepts user input information with the help of substitution variable. Substitute variable can not be used to output va...
-
Finally continue statement added to oracle 11g PL/SQL language. It signals an immediate end to a loop iteration and return to first statemen...
No comments:
Post a Comment