我正在尝试使用类型的Varray来填充它,但是我很着急并且找不到任何有用的示例。
arr=[[1,'A'],[2,'B'],[3,'C']]
这是我的代码:
create table my_table (NUM_OPERACIO NUMBER,TITULS varchar2(3)) ;
insert into my_table values(1,'A');
insert into my_table values(2,'B');
insert into my_table values(3,'C');
create TYPE item IS object( NUM_OPERACIO NUMBER, TITULS varchar2(3));
/
create TYPE arr IS VARRAY(10) OF item;
/
insert into arr values( select NUM_OPERACIO, TITULS from my_table);
FOR i IN 1..3 loop
dbms_output.put_line(arr (i));
END loop;
请帮我解决这个问题。
提前致谢
答案 0 :(得分:2)
Oracle安装程序:
create table my_table (NUM_OPERACIO NUMBER,TITULS varchar2(3)) ;
insert into my_table values(1,'A');
insert into my_table values(2,'B');
insert into my_table values(3,'C');
CREATE TYPE item IS object( NUM_OPERACIO NUMBER, TITULS varchar2(3));
/
CREATE TYPE item_array IS VARRAY(10) OF item;
/
<强> PL / SQL 强>:
DECLARE
arr item_array;
BEGIN
SELECT item( NUM_OPERACIO,TITULS )
BULK COLLECT INTO arr
FROM my_table;
FOR i IN 1..arr.COUNT loop
dbms_output.put_line(arr(i).NUM_OPERACIO || ', ' || arr(i).TITULS);
END loop;
END;
/