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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!