cur1
在以下过程中出现光标错误。我可以像这样创建第二个光标吗?如果没有,请提出建议。
procedure my_procedure as
cursor cur is
select objects,un_fact,min__dt min, max_dt max
from table1 obj
where obj.o = 'SOMECONDITION';
-- below pat_key is a table type of varchar2
patkey_id pat_key;
var_attr number;
begin
for x in cur loop
begin
patkey_id := null;
var_attr:=null;
select t2.pat_key bulk collect into patkey_id
from table2 t2, table1 o
where t2.obj_id = x.objects
and t2.pat_key = o.key;
if length(patkey_id) = 0 then
select t2.pat_key bulk collect into patkey_id
from table2 t2,table1 o
where some other conditions;
end if;
for i in patkey_id.first..patkey_id.last loop
if var_attr = null then
var_attr := patkey_id(0);
else
var_attr := var_attr||','||patkey_id(i);
end if;
end loop;
-- another cursor
cursor cur1 is
SELECT key_1,key_2
FROM table3 t3
WHERE t3.pat_key_id = x.min
and t3.some1= x.max
and t3.some2= var_attr;
begin
for y in cur1 loop
begin
if t3.key_1 = 'something1' then
--update or insert
elsif t3.key_1='something2' then
--update or insert;
end if;
end loop;
end loop;
end my_procedure;