两个表,多条数据循环,游标+存储过程

来源:互联网 发布:易分销 源码 编辑:程序博客网 时间:2024/05/21 20:23

create procedure Test as
cursor c_rows is select distinct c_id from customer;
v_cid customer.cid%type;
v_ocid order.c_id%type;
v_count number;
v_cname customer.cname%type;
begin
open c_rows;
loop
fetch c_rows into v_cid;
exit when c_rows%notfound;
select count(o_id) into v_count from order where c_id=v_cid and date='2013-11-11';
if v_count>1 then
select c_id,c_name into v_oid,v_cname from customer where c_id=v_id;
dbms_output.putline(v_cid);
dbms_output.putline(v_cname);
end if;
end loop;
close c_rows;
end;
原创粉丝点击