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;
PL/SQL游标示例
本文介绍了一个使用PL/SQL编写的示例程序,该程序通过定义游标来查询客户表中的特定记录,并统计每个客户的订单数量。当订单数量超过一定阈值时,将输出客户的ID和姓名。
5675

被折叠的 条评论
为什么被折叠?



