oracle怎么创建返回表的函数和过程?
selectname,包裹数fromrecipientnaturaljoin(selectrecipient_phone_numasphone_num,count(SHI...
select name,包裹数 from recipient natural join (
select recipient_phone_num as phone_num, count(SHIPPER_PHONE_NUM) as 包裹数
from order_table where operator=0213 and recipient_phone_num
in( select phone_num from recipient) group by recipient_phone_num);
===========================================================
以上语句将返回operator号位0213的一个订单表。(下图)
请编写过程find_pro(operator_number)和函数find_fun(operator_number)实现表查询。用户可以直接输入find_pro(0213)或find_fun(0213)得到同样的表 展开
select recipient_phone_num as phone_num, count(SHIPPER_PHONE_NUM) as 包裹数
from order_table where operator=0213 and recipient_phone_num
in( select phone_num from recipient) group by recipient_phone_num);
===========================================================
以上语句将返回operator号位0213的一个订单表。(下图)
请编写过程find_pro(operator_number)和函数find_fun(operator_number)实现表查询。用户可以直接输入find_pro(0213)或find_fun(0213)得到同样的表 展开
1个回答
展开全部
作为结果返回,这正是引用游标SYS_REFCURSOR或者类型TABLE TYPE来实现的功能。
追问
麻烦 给出实现代码
追答
存储过程参考代码:
CREATE OR REPLACE PROCEDURE find_pro (抛砖引玉,码字组织思路、查询语法还是要自己动手才能丰衣足食。
P_OPERATOR IN NUMBER,
O_SRF OUT SYS_REFCURSOR)
AS
BEGIN
OPEN O_SRF FOR
select name,包裹数 from recipient
natural join (
select recipient_phone_num as phone_num, count(SHIPPER_PHONE_NUM) as 包裹数
from order_table where operator=P_OPERATOR
and recipient_phone_num in(
select phone_num from recipient
) group by recipient_phone_num);
END;
/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询