搜索的CASE语句没有选择器,并且该语句的WHEN子句包含提供布尔值的搜索条件。
Searched CASE - 语法
PL/SQL中搜索到的case语句的语法为-
CASE WHEN selector='value1' THEN S1; WHEN selector='value2' THEN S2; WHEN selector='value3' THEN S3; ... ELSE Sn; -- default case END CASE;
Searched CASE - 示例
DECLARE grade char(1) := 'B'; BEGIN case when grade = 'A' then dbms_output.put_line('Excellent'); when grade = 'B' then dbms_output.put_line('Very good'); when grade = 'C' then dbms_output.put_line('Well done'); when grade = 'D' then dbms_output.put_line('You passed'); when grade = 'F' then dbms_output.put_line('Better try again'); else dbms_output.put_line('No such grade'); end case; END; /
当以上代码在SQL提示符下执行时,将产生以下输出-
Very good PL/SQL procedure successfully completed.
参考链接
https://www.learnfk.com/plsql/plsql-searched-case.html
标签:CASE,dbms,grade,无涯,SQL,put,output,line From: https://blog.51cto.com/u_14033984/8945050