declare
v_orgid varchar2(20);
v_count BINARY_INTEGER;
cursor c_Orgid is
select hou.organization_id from hr_operating_units hou;
begin
open c_Orgid;
loop
fetch c_Orgid into v_orgid;
select count(*) into v_count from pa_projects_all ppa where ppa.carrying_out_organization_id=v_orgid;--必须把变量放在into后的变量里,因为实在函数内
dbms_output.put_line(v_count);
--dbms_output.put_line(v_orgid);--若放在此处则会多打印一次,因为游标还没有关闭
exit when c_Orgid%NOTFOUND;
dbms_output.put_line(v_orgid);
end loop;
end;
v_orgid varchar2(20);
v_count BINARY_INTEGER;
cursor c_Orgid is
select hou.organization_id from hr_operating_units hou;
begin
open c_Orgid;
loop
fetch c_Orgid into v_orgid;
select count(*) into v_count from pa_projects_all ppa where ppa.carrying_out_organization_id=v_orgid;--必须把变量放在into后的变量里,因为实在函数内
dbms_output.put_line(v_count);
--dbms_output.put_line(v_orgid);--若放在此处则会多打印一次,因为游标还没有关闭
exit when c_Orgid%NOTFOUND;
dbms_output.put_line(v_orgid);
end loop;
end;