gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 18:18:25 26 4
gpt4 key购买 nike

我想写一个循环遍历数字 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;

最佳答案

另一种方法:

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;
/

关于sql - 如何在 pl/sql 中编写遍历数字的循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com