Oracle PL/SQL 浅析IF和ELSIF的不平等
之前写过一篇博客,叫:Oracle PL/SQL 从if 到 then的“艺术鉴赏”,地址:点击打开链接
现在范围扩展至每个平行的IF条件,是否应该注意点啥
在条件是平行的时候,是否IF一定是可以无序的呢?
先看个小实验:
hr@ORCL> edWrote file afiedt.buf 1 create or replace procedure p_test_if(p_num pls_integer) 2 as 3 v_num PLS_INTEGER:=p_num; 4 begin 5 for i in 1..1000000 6 loop 7 if p_num=1 8 then 9 v_num:=p_num+1; 10 elsif p_num=2 11 then 12 v_num:=p_num+1; 13 elsif p_num=3 14 then 15 v_num:=p_num+1; 16 else 17 v_num:=p_num+1; 18 end if; 19 end loop; 20* end p_test_if;hr@ORCL> /Procedure created.hr@ORCL> set timing onhr@ORCL> exec p_test_if(1);PL/SQL procedure successfully completed.Elapsed: 00:00:00.13hr@ORCL> exec p_test_if(2);PL/SQL procedure successfully completed.Elapsed: 00:00:00.18hr@ORCL> exec p_test_if(3);PL/SQL procedure successfully completed.Elapsed: 00:00:00.25