Oracle if else if for case
生活随笔
收集整理的這篇文章主要介紹了
Oracle if else if for case
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
------------------游標+for+if else if
DECLARE cursor s_cursor is SELECT * from emp;--定義游標
beginfor r in s_cursor loop--循環if r.deptno=10--if判斷then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);else if r.deptno=20then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);else if r.deptno=30then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);end if;end if;end if;end loop;
end;
-----------------------case
select ename, deptno, sal,
casewhen deptno=10 then sal+10when deptno=20 then sal+20else sal end as addsal
from emp;
-------------if
beginif(1!=1)thendbms_output.put_line('000'); else if(10>2)thendbms_output.put_line('abc'); end if;end if;---注意這里
end;-----------for循環
DECLARE num number;
beginselect count(*) into num from emp;for r in 1..numloopdbms_output.put_line(r);end loop;
end;
轉載于:https://www.cnblogs.com/Evan-Pei/p/4686306.html
總結
以上是生活随笔為你收集整理的Oracle if else if for case的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL 常用30种SQL查询语句优化
- 下一篇: AtCoder Grand Contes