上文测试了oracle plsql循环比较集合元素是否相同
http://space.itpub.net/9240380/viewspace-713314
随即又测试如下代码:
declare
cursor cur_emp is select deptno from emp order by deptno;
v_deptno emp.deptno%type;
v_1 emp.deptno%type;
begin
open cur_emp;
loop
fetch cur_emp into v_deptno;
exit when cur_emp%notfound;
if cur_emp%rowcount=1 then
dbms_output.put_line(v_deptno);
end if;
if v_1!=v_deptno then
dbms_output.put_line(v_deptno);
end if;
v_1:=v_deptno;
end loop;
close cur_emp;
end;
备注:
测试表数据皆一致,俱为oracle之scott用户的emp表
http://space.itpub.net/9240380/viewspace-713314
随即又测试如下代码:
declare
cursor cur_emp is select deptno from emp order by deptno;
v_deptno emp.deptno%type;
v_1 emp.deptno%type;
begin
open cur_emp;
loop
fetch cur_emp into v_deptno;
exit when cur_emp%notfound;
if cur_emp%rowcount=1 then
dbms_output.put_line(v_deptno);
end if;
if v_1!=v_deptno then
dbms_output.put_line(v_deptno);
end if;
v_1:=v_deptno;
end loop;
close cur_emp;
end;
备注:
测试表数据皆一致,俱为oracle之scott用户的emp表
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-713318/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-713318/