PL/SQL FORALL

forall语法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
DECLARE
V_INPUT_STR VARCHAR2(1000);
V_INSER_SQL VARCHAR2(1000);
V_STR_LIST DBMS_SQL.VARCHAR2S;
BEGIN
V_INPUT_STR := '2003130, 2003131, 2003132, 2003116, 2001100,,2001101,';
V_STR_LIST := TEST_STRING_TO_LIST(V_INPUT_STR, ',', FALSE);
FORALL V_INDEX IN V_STR_LIST.FIRST .. V_STR_LIST.LAST
INSERT INTO GT_KM_IMP
(ITEMCODE)
VALUES
(:ITEMCODE) USING V_STR_LIST
(V_INDEX);
END;

DECLARE
V_INPUT_STR VARCHAR2(1000);
V_INSER_SQL VARCHAR2(1000);
V_STR_LIST DBMS_SQL.VARCHAR2S;
BEGIN
V_INPUT_STR := '2003130, 2003131, 2003132, 2003116, 2001100,,2001101,';
V_STR_LIST := TEST_STRING_TO_LIST(V_INPUT_STR, ',', FALSE);
FORALL V_INDEX IN INDICES OF
V_STR_LIST BETWEEN V_STR_LIST.FIRST AND V_STR_LIST.LAST
INSERT INTO GT_KM_IMP (ITEMCODE) VALUES (V_STR_LIST(V_INDEX));
END;