如何在pl/sql中编写循环数字的循环

lea*_*sql 4 sql oracle plsql

我想写一个迭代数字的循环 105 102 19 17 101 16 106 107

对于每次迭代,我想在查询中插入数字并将其插入表中.

伪:

LOOP (105 102 19 17 101 16 106 107)
   FETCH select * from some_table where value=current_iteration_index --105..etc.
   INTO my_rec_type

END LOOP;
Run Code Online (Sandbox Code Playgroud)

dpb*_*ley 12

另一种方法:

declare
 type numListType is table of number;
 numList numListType;
begin
numList := numListType(
 105,102,19,17,101,16,106,107 
);
for i in numList.FIRST..numList.LAST loop
 -- your usage of element goes here
 dbms_output.put_line(numList(i));
end loop;
end;
/
Run Code Online (Sandbox Code Playgroud)