首页 > 代码库 > plsqlcase选择语句

plsqlcase选择语句

case选择语句的基本形式:

CASE selector

WHEN expression1 THEN result1

WHEN expression2 THEN result2

WHEN expressionN THEN resultN

[ ELSE resultN+1]

END CASE;

基本的运用

DECLARE
V_grade char(1) := upper(‘&p_grade‘);
V_appraisal varchar2(20);
BEGIN
v_appraisal :=
case v_grade
when ‘A‘ then ‘Excellent‘
when ‘B‘ then ‘Very good‘
when ‘c‘ then ‘good‘
else ‘No such grade‘
end;
dbms_output.put_line(‘grade:‘||v_grade||‘Appraisal: ‘||v_appraisal);
END;

plsqlcase选择语句