我的代码有误
PLS-00540:在此上下文中不支持的对象
问题是我无法以某种方式声明已声明的2D数组。当我查看类型的示例以及如何放置值时,一切都很好,但事实并非如此。我不知道为什么问题出在我的类型节点上。
有什么想法吗?
declare
type node as object
(
v_value int,
v_x int,
v_y int,
is_visited int,
s_way varchar(50)
);
type matrix_array is table of node;
type matrix_type is table of matrix_array;
matrix matrix_type := matrix_type();
cursor c_matrix is
select g.id, x1, x2, x3, x4, x5, x6, x7 from table t;
v_value int;
v_id int;
v_1 int;
v_2 int;
...
v_7 int;
begin
for i in 1 .. 7 loop
insert into table
(id, x1, x2, x3, x4, x5, x6, x7)
values
(i,
round(dbms_random.value(low => 1, high => 6)),
...
round(dbms_random.value(low => 1, high => 6)));
end loop;
open c_matrix;
matrix:=matrix_type();
matrix.extend(7);
for i in 1 .. 7 loop
matrix(i):=matrix_array();
matrix(i).extend(7);
fetch c_matrix
into v_id, v_1, v_2, v_3, v_4, v_5, v_6, v_7;
matrix(i)(1) :=node( v_1, i, 1, 0, '');
...
matrix(i)(7) := node( v_7, i, 7, 0, '');
end loop;
end;
答案 0 :(得分:1)
您需要从PL / SQL块之外创建node
类型:
create or replace type node as object
(
v_value int,
v_x int,
v_y int,
is_visited int,
s_way varchar(50)
);
declare
type matrix_array is table of node;
type matrix_type is table of matrix_array;
matrix matrix_type := matrix_type();
cursor c_matrix is
select id, x1, x2, x3, x4, x5, x6, x7 from tableT;
...
begin
...
end;