我想在下面提到的存储过程中删除多余的计数请求,而是想使用一个临时表并使用该临时表返回游标
procedure status(p_order_id in varchar2, p_stat out sys_refcursor) is
l_count pls_integer;
begin
select count(*) into l_count
from order o
where o.order_id=p_order_id;
if l_count > 0 then
-- exists in main table so only query that
open p_stat for select o.status_code,o.order_id
from order o
where o.order_id=p_order_id;
else -- does not exist in main table so only query archive
open p_stat for select a.status_code,a.order_id
from order_archive a where a.order_id=p_order_id;
end if;
end status;