环境0racle8I
我的问题是用下面方法把表里多行输出来,不想用多个索引表。DECLARE
TYPE EmpTabTyp IS TABLE OF user_msg%ROWTYpe
Index by binary_integer;
emp_tab EmpTabTyp;
i integer;
BEGIN
Select msg_title BULK COLLECT INTO emp_tab From user_msg ; /*此行有问题*/
For i in 1..emp_tab.count loop
Dbms_Output.Put_Line(emp_tab.count);
dbms_output.put_line(emp_tab(i).msg_code || ' ' || emp_tab(i).msg_title);
End Loop;
END
;
我的问题是用下面方法把表里多行输出来,不想用多个索引表。DECLARE
TYPE EmpTabTyp IS TABLE OF user_msg%ROWTYpe
Index by binary_integer;
emp_tab EmpTabTyp;
i integer;
BEGIN
Select msg_title BULK COLLECT INTO emp_tab From user_msg ; /*此行有问题*/
For i in 1..emp_tab.count loop
Dbms_Output.Put_Line(emp_tab.count);
dbms_output.put_line(emp_tab(i).msg_code || ' ' || emp_tab(i).msg_title);
End Loop;
END
;
解决方案 »
- ORACLE 版本, 数据库的导入和导出问题。
- Oracle 语法问题
- 一道关于SQL的面试题,大家帮我看看
- 64位的cpu下,安装64位的linux系统,再安装64位的oracle 9i的版本问题
- 一个列转行的问题
- ssi oracle 日期类型入库 时分秒丢失问题 急急急
- 关于临时表权限的问题(global temporary table)
- 求一SQL语句
- 怎样在sql*plus中打开、关闭本机的第二个数据库?
- 我已经快疯了:一个查询SQL语句在查询时只有一条记录,但放在函数中调试时总提示"ORA-01422: 实际返回的行数超出请求的行数"错误,详情内
- 求助! 是否有办法向分区表的各个分区同时insert批量数据?
- 如何查询具有某个角色的所有用户?
TYPE EmpTabTyp IS TABLE OF user_msg%ROWTYpe
Index by binary_integer;
emp_tab EmpTabTyp;
i integer;
BEGIN
Select msg_title, BULK ,COLLECT INTO emp_tab From user_msg ; /*此行有问题*/
For i in 1..emp_tab.count loop
Dbms_Output.Put_Line(emp_tab.count);
dbms_output.put_line(emp_tab(i).msg_code || ' ' || emp_tab(i).msg_title);
End Loop;
END
;
TYPE EmpTabTyp IS TABLE OF user_msg%ROWTYpe
Index by binary_integer;
emp_tab EmpTabTyp;
i integer;
DECLARE
TYPE EmpTabTyp IS TABLE OF user_msg%ROWTYpe
Index by binary_integer;
emp_tab EmpTabTyp;
i integer;
BEGIN
Select * BULK COLLECT INTO emp_tab From user_msg ;
For i in 1..emp_tab.count loop
Dbms_Output.Put_Line(emp_tab.count);
dbms_output.put_line(emp_tab(i).msg_code || ' ' || emp_tab(i).msg_title);
End Loop;
END
;
BULK COLLECT INTO 是不是不支持这种写法
ERROR是 expression 'EMP_TAB' in the INTO list is of wrong type
不过就你所述的功能干嘛那么麻烦,set serveroutput on size 1000000declare
rows integer default 1;
begin
for x in (select * from user_msg) loop
dbms_output.put_line(rows);
dbms_output.put_line(x.msg_code||' '||x.msg_title);
rows:=rows+1;
end loop;
end ;
/
如果只实现功能我作select就可了
其实我是想知道oracle中怎样把表里内容放入索引表中,我不想为所有栏位都定义一个索引表
并想批处理,所以用了上面的写法,不知道什么原因没有通过,oracle能否把某个结果放入索引
表中,怎么实现,我想知道的就是这个。多谢njhart2003
create or replace procedure test
is
type t_province is table of city.provinceid%type index by binary_integer;
type t_city is table of city.cityid%type index by binary_integer;
type t_name is table of city.name%type index by binary_integer;
pid t_province;
cid t_city;
nm t_name;
begin pid.delete;
cid.delete;
nm.delete;
select * BULK COLLECT into pid,cid,nm from city; for x in 1..nm.count loop
dbms_output.put_line(nm(x));
end loop; end test;
----------------------------------oracle9 release 2 可以用一个索引表装一个纪录集。