我在循环中编写了一个带有查询的存储过程。 此查询将记录设置为RECORD类型的自定义数据类型,如
TYPE finalrecord
IS
RECORD
(
corh VARCHAR2(1),
myspissueid NUMBER(10),
mypkey VARCHAR2(10),
mycreated DATE,
myprevstepname VARCHAR2(10),
mystepname VARCHAR2(10),
mystorypoints NUMBER(2) );
myfinalrecord finalrecord;
for循环就像
for vh in (select * from table1 where abc=3)
loop
select steps.current_or_history,
steps.issueid,
steps.pkey,
steps.created,
steps.prev_step_name,
steps.step_name,
steps.story_points
from steps where column1 = 'xyz' and column2=vh.column2;
end loop;
每次执行内部循环时,SELECT语句将返回多个记录。我想将此记录添加到主变量(作为集合..但是varray或嵌套表或关联数组),并将该变量作为存储过程的输出返回。
有什么想法吗?
答案 0 :(得分:0)
declare
type t is table of finalrecord;
my_table t;
begin
for vh in (select * from table1 where abc = 3) loop
execute immediate 'select finalrecord(steps.current_or_history,
steps.issueid,
steps.pkey,
steps.created,
steps.prev_step_name,
steps.step_name,
steps.story_points)
from steps where column1 = ''xyz'' and column2=vh.column2' bulk
collect
into my_table;
end loop;
end;
你可以尝试这个,如果它有效,你也可以创建程序......