首页 > 数据库 > Oracle > 浅析IF和ELSIF的不平等
先看个小实验:
hr@ORCL> ed Wrote 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 on hr@ORCL> exec p_test_if(1); PL/SQL procedure successfully completed. Elapsed: 00:00:00.13 hr@ORCL> exec p_test_if(2); PL/SQL procedure successfully completed. Elapsed: 00:00:00.18 hr@ORCL> exec p_test_if(3); PL/SQL procedure successfully completed. Elapsed: 00:00:00.25
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26515977/viewspace-1207961/ ,如需转载,请注明出处,否则将追究法律责任。