------------------游标+for+if else if
DECLARE cursor s_cursor is SELECT * from emp;--定义游标
begin
for r in s_cursor loop--循环
if r.deptno=10--if判断
then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);
else if r.deptno=20
then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);
else if r.deptno=30
then dbms_output.put_line('名字:'||r.ename||'sal'||r.sal);
end if;end if;end if;
end loop;
end;
-----------------------case
select ename, deptno, sal,
case
when deptno=10 then sal+10
when deptno=20 then sal+20
else sal end as addsal
from emp;
-------------if
begin
if(1!=1)
then
dbms_output.put_line('000');
else if(10>2)
then
dbms_output.put_line('abc');
end if;
end if;---注意这里
end;
-----------for循环
DECLARE num number;
begin
select count(*) into num from emp;
for r in 1..num
loop
dbms_output.put_line(r);
end loop;
end;