您的位置:首页 > 其它

项目实例 声明包 创建存储过程,调用

2015-03-31 14:43 316 查看
--声明包
create or replace package pkg_region_to_region
as
type  type_cursor is ref cursor;
procedure read_rows (header varchar2, result out type_cursor);
end pkg_region_to_region;

--创建存储过程
create or replace package body pkg_region_to_region
as
procedure read_rows(header varchar2, result out type_cursor)
is
sqlText varchar2(5000);
begin
open result for
select  * from (
select count(*), br2.name, br2.code,header startcode
from (select *
from (select R.name      startname,
R.code      startcode,
B.stationid startstationid
from Region R
left join BASECELLSTATION B

on B.region = R.code) br
left join (select t.*, t.DESTINATIONSTATION stationid
from TRIPINFO t) TR
on tr.stationid = br.startstationid
where startcode = header
order by startcode) TT1
left join (select R.name name, R.code code, B.stationid stationid
from Region R
left join BASECELLSTATION B

on B.region = R.code) br2
on br2.stationid = TT1.ORIGINSTATION
GROUP by br2.code, br2.name
order by br2.code);
--dbms_output.put_line(sqlText);
--sqlText;
end read_rows;
end pkg_region_to_region;

--调用存储过程
var result refcursor
exec pkg_region_to_region.read_rows('1',:result);
print result
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: