职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 737|回复: 1

PL/SQL游标问题

[复制链接]
陈和陈 发表于 2009-8-23 10:54 | 显示全部楼层 |阅读模式
使用游标计算所有售货员的佣金:
create or replace procedure do_commissions
is
commission_rate number:=2;
total_sale number:=0;
current_person varchar2(3):=' ';
next_person varchar2(3);
quantity_sold number:=0;
item_price number:=0;

cursor sales_cur /*声明游标*/
is
select pur.salesperson, pur.quantity,pro.p_price
from purchase pur,product pro
where pur.p_name=pro.p_name
order by salesperson;
begin
open sales_cur;/*打开游标*/
loop
fetch sales_curinto
next_person,quantity_sold,item_price; /*获取游标*/
where(next_person=current_person
and
sales_cur%found)
loop
total_sale:=total_sale+quantity_sold*item_price;
fetch sales_cur into
next_person,quantity_sold,item_price;
end loop;
if(sales_cur%found)
then
if(current_person!=next_person)
then
if(current_person!=' ')
then
dbms_output.put_line
( current_person || ' ' ||total_sale || ' ' || total_sale*commission_rat/100);
end if;
total_sale:=quantity_sold*item_price;
current_person:=next_person;
end if;
else if(current_person!=' ')
then
dbms_output.put_line
(current_person || ' ' || total_sale || ' ' ||total_sale*commission_rat/100);
end if;
end if;
exit when sales_cur%notfound;
endloop;
close sales_cur;/*关闭游标*/
end do_commissions;
//警告: 创建的过程带有编译错误
//
?????????????
zqm 发表于 2009-8-23 10:55 | 显示全部楼层

PL/SQL游标问题

你没有plsql吗?在plsql里边编辑此过程
然后运行的时候如果有什么错误就会提示错误了
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-5-5 13:12 , Processed in 0.126143 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表