ORA-00947 全局声明类型时值不足

ORA-00947 Not enough values while declaring type globally(ORA-00947 全局声明类型时值不足)
本文介绍了ORA-00947 全局声明类型时值不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 create table foo(
   id number,
   status varchar2(10)
 );

表已创建.

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: 值不够错误

ORA-00947: not enough values error

但是,当我声明一个记录类型和该记录类型的嵌套表,然后在包内声明一个嵌套表的变量时,那么上面的批量收集工作并且不会抛出错误

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?

推荐答案

您不能只是将值放入对象表中 - 您需要将值转换为适当类型的对象,然后插入对象.试试

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!

分享和享受.

这篇关于ORA-00947 全局声明类型时值不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)