用函数实现如下:
SQL> create or replace type myobjectype as object (x int,y date,z varchar2(50));
2 /
Type created.
SQL> create or replace type mytabletype as table of myobjectype
2 /
Type created.
--创建可以返回纪录集的函数(不传入表名参数)
SQL> create or replace function testrerecordnotabname (tableid in number)
2 return mytabletype
3 as
4 l_data mytabletype :=mytabletype();
5 begin
6 for i in (select * from a where id>=tableid) loop
7 l_data.extend;
8 l_data(l_data.count) := myobjectype(i.id,i.doctime,i.name);
9 exit when i.id = 62;
10 end loop;
11 return l_data;
12 end;
13 /
Function created.
SQL> create or replace type myobjectype as object (x int,y date,z varchar2(50));
2 /
Type created.
SQL> create or replace type mytabletype as table of myobjectype
2 /
Type created.
--创建可以返回纪录集的函数(不传入表名参数)
SQL> create or replace function testrerecordnotabname (tableid in number)
2 return mytabletype
3 as
4 l_data mytabletype :=mytabletype();
5 begin
6 for i in (select * from a where id>=tableid) loop
7 l_data.extend;
8 l_data(l_data.count) := myobjectype(i.id,i.doctime,i.name);
9 exit when i.id = 62;
10 end loop;
11 return l_data;
12 end;
13 /
Function created.
解决方案 »
- 我建表时设置不了pctused和next值,建表后也改不了。
- ora-06531:引用未初始化的收集
- oracle中如何将两边的空格去掉
- 150分相送讨教个奇怪问题,创建表PRIMARY KEY的同时,什么时候会不产生对应的索引呢?
- 怎么获取到地图路上的所有点?
- 一段SQL语句 请大家指点
- 有了pl/sql developer还需要toad吗????
- 怎样改变资料库数据文件的建立目标位置呢?我目前的DB_CREATE_FILE_DEST已经改变了,
- 触发器执行出错,请帮忙看看。谢谢
- vfp的DBF数据库怎么导入到ORACLE数据库?
- 感觉自己的oracle805还可以,问题是现在要用817,安装了一个,感觉完全不一样??
- 高手请进:Oracle8.1.5+delphi7错误!
(v_ckdh in number,
v_MC out REC_MC )
as
begin for i in (select fun_id from userfun) loop
v_mc.extend;
v_mc.AA:= i.fun_id;
exit when i.fun_id is null;
end loop;
end;
/
还没测试,此类问题比较麻烦。(建义用游标)
(v_ckdh in number,
REF_MC out REC_MC )
as
begin
open ref_mc for 。就行了哈
end;