A: a b c
B: aa bb cc dd
C: aaa bbb ccc ddd
v_a A.a%type;
v_b A.b%type;
v_c A.c%type;t_a B.aa%type;
t_b B.bb%type;
cursor v_cursor1 is
select a,b,c from A;open v_cursor1;
loop
fetch v_cursor1 into v_a ,v_b ,v_c ;
exit when v_cursor1%notfound;
if v_cursor1%found then
select count(*) into t_a,sum(bb) into t_b from B where cc = '001'; //这里不能使用分组(这里不会产生多条,数据是唯一的),但是我要通过t_a,t_b作为参数来更新,如何解决
update C set aaa= t_a , bbb = t_b where ccc = v_a;
end if;
end loop;
close v_cursor1;
B: aa bb cc dd
C: aaa bbb ccc ddd
v_a A.a%type;
v_b A.b%type;
v_c A.c%type;t_a B.aa%type;
t_b B.bb%type;
cursor v_cursor1 is
select a,b,c from A;open v_cursor1;
loop
fetch v_cursor1 into v_a ,v_b ,v_c ;
exit when v_cursor1%notfound;
if v_cursor1%found then
select count(*) into t_a,sum(bb) into t_b from B where cc = '001'; //这里不能使用分组(这里不会产生多条,数据是唯一的),但是我要通过t_a,t_b作为参数来更新,如何解决
update C set aaa= t_a , bbb = t_b where ccc = v_a;
end if;
end loop;
close v_cursor1;
写成2条select count(*) into t_a from B where cc = '001';
select sum(bb) into t_b from B where cc = '001';