第一种方式:
1
DECLARE
2
TYPE TBL_T IS TABLE OF VARCHAR2(30);
3
MY_TBL TBL_T := TBL_T(); --初始化
4
BEGIN
5
FOR INX IN (SELECT ENAME FROM EMP) LOOP
6
MY_TBL.EXTEND; --扩展
7
MY_TBL(MY_TBL.LAST) := INX.ENAME;
8
END LOOP;
9
-- SELECT ENAME BULK COLLECT INTO MY_TBL FROM EMP;
10
FOR I IN MY_TBL.FIRST..MY_TBL.LAST LOOP
11
DBMS_OUTPUT.PUT_LINE('MY_TBL('||I||') = '||MY_TBL(I));
12
END LOOP;
13
END;
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
第二种方式:
用SELECT ... BULK COLLECT INTO... FROM...语法