似乎没有找到一种方法循环通过PL / SQL数组? [英] Can't seem to find a way to loop through a PL/SQL array?
本文介绍了似乎没有找到一种方法循环通过PL / SQL数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样做:
arrCauses := APEX_UTIL.STRING_TO_TABLE(:P1_CAUSE);
FOR c IN 1..arrCauses.count LOOP
INSERT INTO DT_EVENT_CAUSE (
EVENT_ID,
CAUSE_ID)
VALUES (
nextPK, c);
END LOOP;
或此
arrCauses := APEX_UTIL.STRING_TO_TABLE(:P1_CAUSE);
FOR c IN arrCauses.first..arrCauses.last LOOP
INSERT INTO DT_EVENT_CAUSE (
EVENT_ID,
CAUSE_ID)
VALUES (
nextPK, c);
END LOOP;
问题是... c总是只是计数,所以如果数组是1项,的1将被插入。如果数组如果有3个项目,则c将被插入1,2和3。与数组中的实际值相反。
Problem is...c is always just the count, so if the array is 1 item, a c of 1 will be inserted. If the array if 3 items, c's of 1, 2 and 3 will be inserted. As opposed to actual values from the array. What am I doing wrong?!
推荐答案
使用索引来检索数组中的值:
Use the index to retrieve the value within your array:
VALUES (
nextPK, arrCauses(c));
而不是
VALUES (
nextPK, c);
;)
这篇关于似乎没有找到一种方法循环通过PL / SQL数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文