Oracle笔记之三(Oracle中控制语句)

来源:互联网 发布:微信公众号开发源码 编辑:程序博客网 时间:2024/06/05 20:29
13. Oracle 中逻辑控制语句If elsif else end ifset serverout on;declare per_dep_count number;beginselect count(*) into per_dep_count from emp;if per_dep_count>0 then   dbms_output.put_line('Big Than 0');  elsif per_dep_count>5 then --elsif not elseif!!!!dbms_output.put_line('Big Than 5');  elsedbms_output.put_line('En?');end if;end;14.Case when 的使用的两种方式(1)declare per_dep_count number;beginselect count(*) into per_dep_count from emp;case per_dep_count  when 1 then   dbms_output.put_line('1');  when 2 then   dbms_output.put_line('2');  else   dbms_output.put_line('else');end case;end;(2)declare per_dep_count number;beginselect count(*) into per_dep_count from emp;case when per_dep_count=1 then   dbms_output.put_line('1');when per_dep_count=2 then   dbms_output.put_line('2');else   dbms_output.put_line('else');end case;end;14. While 的使用declare v_id number:=0;begin   while v_id<5 loop v_id:=v_id+1; dbms_output.put_line(v_id); end loop;end;15.For的使用declare v_id number:=0;begin       for v_id in 1..5 loop              dbms_output.put_line(v_id);   end loop;end;

 
原创粉丝点击