【发布时间】:2014-07-17 14:31:54
【问题描述】:
例子是:
CASE
WHEN selector = 'value1' THEN S1;
WHEN selector = 'value2' THEN S2;
WHEN selector = 'value3' THEN S3;
...
ELSE Sn; -- default case
END CASE;
或其他:
IF(boolean_expression 1)THEN
S1; -- Executes when the boolean expression 1 is true
ELSIF( boolean_expression 2) THEN
S2; -- Executes when the boolean expression 2 is true
ELSIF( boolean_expression 3) THEN
S3; -- Executes when the boolean expression 3 is true
ELSE
S4; -- executes when the none of the above condition is true
END IF;
【问题讨论】:
-
我建议您编写一个小基准,运行多次,然后将结果发布为您自己问题的答案。
-
从 11gR1 开始使用 PL/SQL Hierarchical Profiler 分析基准!
-
实际上你不应该为这种微优化而烦恼。我猜编译器将为您的两个示例生成相同的本机/解释代码。相反,请注意 Oracle 数据库文档的 PL/SQL Optimization and Tuning 章中提到的实际性能问题。
标签: if-statement plsql case conditional-statements