请问为什么会出错

supkim 2002-12-11 03:49:56
CREATE OR REPLACE PROCEDURE BASE.T_TEST (
v_test in varchar2
)
AS
type ar is varray(2) of varchar2(2);
v_sign_num ar;
i number(2);
BEGIN
i:=1;
v_sign_num(1) :='s';
v_sign_num(2) :='s';
dbms_output.put_line(v_sign_num(1));

END;
/
上面是一个存储过程,编译已经通过,
但在运行时却报出已下错误信息,哪位大侠能告诉我怎么解决这个问题,谢谢!
错误信息:
ERROR 位于第 1 行:
ORA-06531: Reference to uninitialized collection
ORA-06512: at "BASE.T_TEST", line 10
ORA-06512: at line 1
...全文
43 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jlandzpa 2002-12-11
  • 打赏
  • 举报
回复
小贝说得对.
beckhambobo 2002-12-11
  • 打赏
  • 举报
回复
CREATE OR REPLACE PROCEDURE BASE.T_TEST (
v_test in varchar2
)
AS
type ar is varray(2) of varchar2(2);

v_sign_num ar:=ar(1,2);
i number(2);
BEGIN
i:=1;
v_sign_num(1) :='s';
v_sign_num(2) :='s';
dbms_output.put_line(v_sign_num(1));

END;
beckhambobo 2002-12-11
  • 打赏
  • 举报
回复
可变数组是这样用吗,要在声明中初始化大小,类以于构造器!
wanghai 2002-12-11
  • 打赏
  • 举报
回复
Initializing, Populating, and Referencing Collections
Before a collection can be used, it must be initialized (instantiated). Instantiating
a collection is automatic for index-by tables, but for nested tables
and VARRAYs, you must use a special built-in function called a constructor.
Nested tables and VARRAYs, if you recall, start out atomically NULL—that is,
the whole collection is NULL, not just the elements. As in a record, values
can be assigned to a collection en masse or piecemeal. Assigning values to
elements in a collection requires use of subscript notation for the element.
To assign one whole collection to another en masse, you simply use the
assignment operator. Let’s look at examples of initializing and populating
collections.
jiezhi 2002-12-11
  • 打赏
  • 举报
回复
集合没有给初始值。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧