Syntax:
CASE selector
WHEN 'value1' THEN S1;
WHEN 'value2' THEN S2;
WHEN 'value3' THEN S3;
...
ELSE Sn; -- default case
END CASE;
Sample code:
DECLARE
grade varchar2(1) :='&grade';
BEGIN
CASE grade
WHEN 'A' THEN
dbms_output.put_line ('your grade is A as your score is above 70');
WHEN 'B' THEN
dbms_output.put_line ('your grade is B as your score is above 60 and below 70');
WHEN 'C' THEN
dbms_output.put_line ('your grade is C as your score is above 50 and below 60');
WHEN 'D' THEN
dbms_output.put_line ('your grade is D as your score is above 40 and below 50');
END CASE;
END;
No comments :
Post a Comment