嵌套表事例和PLS-00642问题
来源:互联网 发布:鞋子淘宝 编辑:程序博客网 时间:2024/05/17 07:50
这是前几天遇到的一个小问题记录下来,呵呵
错误事例:
declare
type tb_type is table of varchar2(32);
v_coll tb_type:=tb_type();
begin
v_coll:=tb_type('xiaowang','xiaoma','gagaga');
for i in (select * from table(v_coll))
loop
dbms_output.put_line(i.column_value);
end loop;
end;
上述代码执行时报错PLS-00642错误,查找该错误含义:
PLS-00642 local collection types not allowed in SQL statements
Cause: A locally-defined (that is not schema level) collection type was used in a SQL statement. The type must be defined in a schema to be accepted in a SQL statement.
Action: Define the collection type in your schema, not inside a PL/SQL subprogram.
即:如果在sql级使用嵌套表或varray数组,则所定义的类型必须是schema级的。
正确事例:
create type tb_type is table of varchar2(32);
declare
v_coll tb_type:=tb_type();
begin
v_coll:=tb_type('xiaowang','xiaoma','gagaga');
for i in (select * from table(v_coll))
loop
dbms_output.put_line(i.column_value);
end loop;
end;
错误事例:
declare
type tb_type is table of varchar2(32);
v_coll tb_type:=tb_type();
begin
v_coll:=tb_type('xiaowang','xiaoma','gagaga');
for i in (select * from table(v_coll))
loop
dbms_output.put_line(i.column_value);
end loop;
end;
上述代码执行时报错PLS-00642错误,查找该错误含义:
PLS-00642 local collection types not allowed in SQL statements
Cause: A locally-defined (that is not schema level) collection type was used in a SQL statement. The type must be defined in a schema to be accepted in a SQL statement.
Action: Define the collection type in your schema, not inside a PL/SQL subprogram.
即:如果在sql级使用嵌套表或varray数组,则所定义的类型必须是schema级的。
正确事例:
create type tb_type is table of varchar2(32);
declare
v_coll tb_type:=tb_type();
begin
v_coll:=tb_type('xiaowang','xiaoma','gagaga');
for i in (select * from table(v_coll))
loop
dbms_output.put_line(i.column_value);
end loop;
end;
- 嵌套表事例和PLS-00642问题
- PLS-00642
- mysql 存储过程1064问题和事例
- oracle pls-00201 问题
- PLS-00201 DBMS_AQ 看不到问题
- PLS-00201和IMP-00013
- sql select 嵌套select 小事例
- DOM_介绍和事例
- ScrollView和RecyclerView嵌套问题
- ScrollView 和 RecyclerView 嵌套问题
- dom4j 使用事例,及问题
- c++中的函数嵌套调用和嵌套定义问题
- 函数指针和多线程事例
- XMLHttpRequest对象详解和事例
- Java synchronized使用的 正确事例和错误事例
- 关于handle_level_irq、handle_edge_irq和中断嵌套问题
- scrollview和viewpager嵌套冲突的问题
- ScrollView和ViewPager嵌套的问题
- TCP/IP 三次握手
- 如何有效使用bitmap
- 关于虚拟主机上的简单全文索引解决方案
- HDU 2026 - 首字母变大写
- 最火爆的开源流式系统Storm vs 新星Samza
- 嵌套表事例和PLS-00642问题
- 2014找工之递归一类问题
- ZOJ3733 Skycity
- 如何把int类型的数值转变成String字符串的类型。
- 在android、网页等获取linux 平台下的dlna dmp的中文名字乱码
- poj1182 食物链
- 一种在客户端利用js实现对数据校验的方法
- 802.11 学习笔记
- java当中equals函数的作用小结