oracle存储过程如何输出结果集?

applelvv applelvv 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
网上搜到说用游标实现,我写了如下存储过程,请大侠看看我怎么得不到结果呢?
初学者,不知存储过程写的是否正确,请大家说的详细点。

CREATE OR REPLACE PACKAGE P_SEARCH_ERROR_PACKAGE AS
TYPE OUT_CUR IS REF CURSOR;
end P_SEARCH_ERROR_PACKAGE;


create or replace procedure P_SEARCH_ERROR(v_CO_NBR in varchar2,
v_outmsg out P_SEARCH_ERROR_PACKAGE.OUT_CUR)
AS
begin
declare
v_cfs_co_nbr varchar2(20);
v_cfs_co_id varchar2(16);
oe_hand_flag char(1);
oe_err_info varchar2(2000);
oe_order_error_id number;
begin
open v_outmsg for select distinct cfs.co_nbr,
cfs.co_id,
oe.hand_flag,
oe.err_info,
oe.order_error_id
into v_cfs_co_nbr,v_cfs_co_id,oe_hand_flag,oe_err_info,oe_order_error_id
from sp.crm_for_sa cfs, sp.order_error oe
where cfs.co_id = oe.co_id
and cfs.co_id in (select co_id
from crm.cust_order co
where co.co_nbr = v_CO_NBR)
and oe.hand_flag = 'D';

open v_outmsg for select distinct cfs.co_nbr,
cfs.co_id,
oe.hand_flag,
oe.err_info,
oe.order_error_id
into v_cfs_co_nbr,v_cfs_co_id,oe_hand_flag,oe_err_info,oe_order_error_id
from sp.crm_for_sa cfs, sp.order_error oe
where cfs.order_id = oe.order_id
and cfs.co_nbr = v_CO_NBR
and oe.hand_flag = 'D';

open v_outmsg for select distinct co.co_nbr,
co.co_id,
oe.hand_flag,
oe.err_info,
oe.order_error_id
into v_cfs_co_nbr,v_cfs_co_id,oe_hand_flag,oe_err_info,oe_order_error_id
from crm.cust_order co, sp.order_error oe
where co.co_id = oe.co_id
and co.co_nbr =v_CO_NBR
and oe.hand_flag = 'D';

exception
WHEN OTHERS THEN
ROLLBACK;
end;
end;


...全文
评论 12
收藏 已收藏
分享
返回顶部
applelvv
Oracle 17,134 成员 55,258 内容