oracle 嵌套表各种使用方法示例
2012-01-27 08:14
393 查看
create or replace package dp_nest_test is
function get_lx3_types return t_nest_type;
function ret_lx3_point(r sys_refcursor) return t_nest_type;
function ret_pipe return t_nest_type_r pipelined;
end;
/
create or replace package body dp_nest_test is
function get_lx3_types return t_nest_type is
v_nest_type t_nest_type:=t_nest_type('');
begin
select type bulk collect into v_nest_type from lx3;
return v_nest_type;
end;
function ret_lx3_point(r sys_refcursor) return t_nest_type is
v_nest_tab t_nest_type:=t_nest_type();
k int :=1;
t varchar2(200);
begin
loop
fetch r into t;
if r%notfound then
exit;
end if;
v_nest_tab.extend;
v_nest_tab(k):=t||'('||ascii(t)||')';
k:=k+1;
end loop;
return v_nest_tab;
end;
function ret_pipe return t_nest_type_r pipelined is
v_lx3_r r_lx3:=r_lx3('','');
begin
for i in(select xh,type from lx3) loop
v_lx3_r.xh:=i.xh;
v_lx3_r.type:=i.type;
--pipe row(v_lx3_r);
pipe row(r_lx3(i.xh,i.type));
end loop;
return;
end;
end;
/
select * from table(cast(dp_nest_test.get_lx3_types as t_nest_type));
select *
from table(dp_nest_test.ret_lx3_point(cursor (select type as t_nest_type
from
lx3)));
select * from table(dp_nest_test.ret_pipe);
function get_lx3_types return t_nest_type;
function ret_lx3_point(r sys_refcursor) return t_nest_type;
function ret_pipe return t_nest_type_r pipelined;
end;
/
create or replace package body dp_nest_test is
function get_lx3_types return t_nest_type is
v_nest_type t_nest_type:=t_nest_type('');
begin
select type bulk collect into v_nest_type from lx3;
return v_nest_type;
end;
function ret_lx3_point(r sys_refcursor) return t_nest_type is
v_nest_tab t_nest_type:=t_nest_type();
k int :=1;
t varchar2(200);
begin
loop
fetch r into t;
if r%notfound then
exit;
end if;
v_nest_tab.extend;
v_nest_tab(k):=t||'('||ascii(t)||')';
k:=k+1;
end loop;
return v_nest_tab;
end;
function ret_pipe return t_nest_type_r pipelined is
v_lx3_r r_lx3:=r_lx3('','');
begin
for i in(select xh,type from lx3) loop
v_lx3_r.xh:=i.xh;
v_lx3_r.type:=i.type;
--pipe row(v_lx3_r);
pipe row(r_lx3(i.xh,i.type));
end loop;
return;
end;
end;
/
select * from table(cast(dp_nest_test.get_lx3_types as t_nest_type));
select *
from table(dp_nest_test.ret_lx3_point(cursor (select type as t_nest_type
from
lx3)));
select * from table(dp_nest_test.ret_pipe);
相关文章推荐
- EFOracleProvider 示例使用的方法 Entity Framework Provider for Oracle 資料收集
- oracle中变长数组varray,嵌套表,集合使用方法
- Python使用cx_Oracle调用Oracle存储过程的方法示例
- oracle中decode函数的使用方法示例
- oracle中变长数组varray,嵌套表,集合使用方法
- oracle round函数的使用方法
- 【Oracle】merge into使用方法
- oracle游标使用示例
- oracle冷备份恢复和oracle异机恢复使用方法
- ORACLE中游标的使用方法
- Java使用注解和动态代理实现方法调用时的日志记录示例
- Oracle SQL 内置函数的使用方法及结果
- [iPhone开发之控件的使用]UILabel的各种属性与方法的使用
- 在小程序中使用canvas的方法示例
- oracle查看创建表的sql语句1,DESCRIBE命令使用方法如下:SQL>descri
- linux下 tar解压 gz解压 bz2等各种解压文件使用方法
- httpclient接口测试利用反射根据方法名执行方法的使用示例
- 改主机名后Oracle OEM无法使用处理方法
- 【Android高级】安卓各种动画使用方法详解
- 使用Oracle连接池错误 Cannot create PoolableConnectionFactory(Io 异常: The Network Adapter could not establish the connection )的解决方法