PL/SQL Control Statement Exercises: Display the description against a grade using CASE statement
PL/SQL Control Statement: Exercise-10 with Solution
Write a PL/SQL program to display the description against a grade using CASE statement.
Sample Solution:
PL/SQL Code:
DECLARE
grd CHAR(1);
BEGIN
-- Accept value for grade
grd := '&new_grd';
CASE grd
WHEN 'A' THEN dbms_output.Put_line('Your Grade is: Outstanding');
WHEN 'B' THEN dbms_output.Put_line('Your Grade is: Excellent');
WHEN 'C' THEN dbms_output.Put_line('Your Grade is: Very Good');
WHEN 'D' THEN dbms_output. Put_line('Your Grade is: Average');
WHEN 'F' THEN dbms_output.Put_line('Your Grade is: Poor');
ELSE dbms_output.Put_line('No such grade in the list.');
END CASE;
END;
/
Sample Output:
Enter value for new_grd: D old 5: grd := '&new_grd'; new 5: grd := 'D'; Your Grade is: Average PL/SQL procedure successfully completed.
Flowchart:
Improve this sample solution and post your code through Disqus
Previous: Write a PL/SQL program to count number of employees in a specific department and check whether this department have any vacancies or not.
Next: Write a PL/SQL program to display the description against a grade using CASE statement with EXCEPTION.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework