Question
2-A) Run the code below which causes an error. A CASE statement must find a matching clause (direct match or ELSE). DECLARE v_val PLS_INTEGER :=
2-A) Run the code below which causes an error. A CASE statement must find a matching clause (direct match or ELSE).
DECLARE
v_val PLS_INTEGER := 2002;
v_message VARCHAR2(50);
BEGIN
CASE v_val
WHEN 2001 THEN
v_message := 'I am 2001';
WHEN 2004 THEN
v_message := 'I am 2004';
WHEN 2005 THEN
v_message := 'I am 2005';
END CASE;
DBMS_OUTPUT.PUT_LINE(v_message);
END;
2-B) Code an EXCEPTION handler named e_errormsg that traps this error and displays No message available if the CASE selector is 2002. This error is not predefined so you will need to name declare an exception and associate the name with the error code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started