Q:

Write a PL/SQL program to display the description against a grade using CASE statement with EXCEPTION

0

Write a PL/SQL program to display the description against a grade using CASE statement with EXCEPTION.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

DECLARE
    grd CHAR(1);
  BEGIN
    -- Accept value for grade
    grd := '&new_grd';
  CASE 
    WHEN grd = 'A' THEN dbms_output.Put_line('Your Grade is: Outstanding');
    WHEN grd = 'B' THEN dbms_output.Put_line('Your Grade is: Excellent');
    WHEN grd = 'C' THEN dbms_output.Put_line('Your Grade is: Very Good');
    WHEN grd = 'D' THEN dbms_output.Put_line('Your Grade is: Average');
    WHEN grd = 'F' THEN dbms_output.Put_line('Your Grade is: Poor');
  END CASE;
EXCEPTION
  WHEN CASE_NOT_FOUND THEN
    dbms_output.Put_line('No such grade in the list.');
  END;
/

Sample Output:

Enter value for new_grd: M
old   5:     grd := '&new_grd';
new   5:     grd := 'M';
No such grade in the list.

PL/SQL procedure successfully completed.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now