oracle ORA-00947 全局声明类型时值不足
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10213489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-00947 Not enough values while declaring type globally
提问by Gaurav Soni
create table foo(
id number,
status varchar2(10)
);
Table created.
表已创建。
insert into foo values( 1, 'open' );
insert into foo values( 2, 'close' );
insert into foo values( 3, 'open' );
insert into foo values( 4, 'open' );
insert into foo values( 5, 'close' );
create type foo_obj is object (
id number,
status varchar2(10)
);
/
create type foo_nt
as table of foo_obj;
/
create or replace package test_bulk
is
procedure temp;
end;
/
create or replace package body test_bulk
is
procedure temp
is
v_nt foo_nt;
begin
select id ,status
bulk collect into v_nt
from foo;
end temp;
end test_bulk;
This is a very odd situation, when I create a type object and nested table of that type Globally and create a variable of the nested table type and bulk collect into that variable I get
这是一个非常奇怪的情况,当我全局创建一个类型对象和该类型的嵌套表并创建一个嵌套表类型的变量并批量收集到该变量时,我得到
ORA-00947: not enough values error
ORA-00947: 值不够错误
However, when I declare a record type and nested table of that record type And then a variable of the nested table Inside the package , then the above bulk collect works and it will not throw error
但是,当我声明一个记录类型和该记录类型的嵌套表然后在包内部声明嵌套表的变量时,则上述批量收集工作并且不会抛出错误
Can anyone help me out with this?
谁能帮我解决这个问题?
回答by Bob Jarvis - Reinstate Monica
You can't just put values into a table of objects - you need to convert the values into objects of the appropriate type and then insert the objects. Try
您不能只是将值放入对象表中 - 您需要将值转换为适当类型的对象,然后插入对象。尝试
procedure temp is
v_nt foo_nt;
begin
select FOO_OBJ(id ,status)
bulk collect into v_nt
from foo;
end temp;
Not tested on animals - you'll be first!
未在动物身上进行测试 - 您将是第一个!
Share and enjoy.
分享和享受。