第一范文网 - 专业文章范例文档资料分享平台

实验6 PLSQL程序设计

来源:用户分享 时间:2025/7/31 22:42:39 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

(4) 创建一个存储过程,以出版社名为参数,输出该出版社出版的所有图书的名称、ISBN、批发价格、零售价格信息。

create or replace procedure proc_get_name( p_title books.title%type) as

cursor c_orderid is select order_id from orders where customer_id=p_customer_id; v_orderid orders.order_id%type;

cursor c_orderitem is select ISBN, sum(quantity) totalnum from orderitem where order_id=v_orderid group by ISBN; v_title books.title%type;

begin

open c_orderid; LOOP

fetch c_orderid into v_orderid;

exit when c_orderid%NOTFOUND; for v_orderitem in c_orderitem LOOP

select title into v_title from books where ISBN=v_orderitem.ISBN; DBMS_OUTPUT.PUT_LINE(p_customer_id||''||v_title||'的数量是'||v_orderitem.totalnum); end LOOP; end LOOP; close c_orderid; end proc_get_orderinfo; /

set serveroutput on declare v_customer number; begin v_customer :=&x; proc_get_orderinfo(v_customer); end; /

(5) 创建一个存储过程,输出每个客户订购的图书的数量、价格总额。

create or replace procedure proc_category_static as

cursor c_all_category is select distinct category from books; v_sum_cost number; begin

for v_each_category in c_all_category LOOP

select sum(retail) into v_sum_cost from books where category=v_each_category.category group by category;

dbms_output.put_line('种类为:'||v_each_category.category||',总价格为:'|| v_sum_cost); END LOOP;

end proc_category_static; /

set serveroutput on

exec proc_category_static; /

(6) 创建一个存储过程,输出销售数量前3名的图书的信息及销售名次。

create or replace procedure proc_category_static as

cursor c_all_category is select distinct category from books; v_sum_retail number; begin

for v_each_category in c_all_category LOOP

select sum(cost) into v_sum_retail from books where category=v_each_category.category group by category;

dbms_output.put_line('种类为:'||v_each_category.category||',数量为:'|| v_sum_retail); END LOOP;

end proc_category_static; /

set serveroutput on

exec proc_category_static;

(7) 创建一个存储过程,输出订购图书数量最多的客户的信息及订购图书的数量。

(8) 创建一个存储过程,输出各类图书中销售数量最多的图书的信息及销售的数量。

(9) 创建一个包,实现查询客户订购图书详细信息的分页显示。

create or replace procedure proc_title_static as

cursor c_all_title is select distinct title from books; v_sum_retail number; begin

for v_each_title in c_all_title LOOP

select sum(cost) into v_sum_retail from books where title=v_each_title.title group by title; dbms_output.put_line('信息为:'||v_each_title.title||',数量为:'|| v_sum_retail); END LOOP; end proc_title_static; /

搜索更多关于: 实验6 PLSQL程序设计 的文档
实验6 PLSQL程序设计.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1e13h3evjy0cqsi0v0jd0weks4q8jb00nuj_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top