CREATE TABLE t (num NUMBER, name VARCHAR2(100))
Table created.
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER
IS
TYPE ibt IS TABLE OF t%ROWTYPE
INDEX BY PLS_INTEGER;
PROCEDURE insert_rows ( rows_in IN ibt );
END;
Package created.
CREATE OR REPLACE PACKAGE BODY pkg
IS
PROCEDURE insert_rows ( rows_in IN ibt )
IS
BEGIN
$IF DBMS_DB_VERSION.VER_LE_10_1
$THEN
/* Remove gaps in the collection */
DECLARE
l_dense t;
l_index PLS_INTEGER := rows_in.FIRST;
BEGIN
WHILE (l_index IS NOT NULL)
LOOP
l_dense (l_dense.COUNT + 1) := rows_in (l_index);
l_index := rows_in.NEXT (l_index);
END LOOP;
FORALL indx IN l_dense.FIRST .. l_dense.LAST
INSERT INTO t VALUES l_dense (indx);
END;
$ELSE
/* Use the very cool INDICES OF feature to
skip over gaps. */
FORALL indx IN INDICES OF rows_in
INSERT INTO t VALUES rows_in (indx);
$END
END insert_rows;
END;
Package Body created.
DECLARE
l_postproc_code DBMS_PREPROCESSOR.source_lines_t;
l_row PLS_INTEGER;
BEGIN
l_postproc_code :=
DBMS_PREPROCESSOR.get_post_processed_source (
'PACKAGE BODY',
SYS_CONTEXT ('userenv', 'current_schema'),
'PKG');
l_row := l_postproc_code.FIRST;
WHILE (l_row IS NOT NULL)
LOOP
DBMS_OUTPUT.put_line (
LPAD (l_row, 3)
|| ' - '
|| RTRIM (l_postproc_code (l_row), CHR (10)));
l_row := l_postproc_code.NEXT (l_row);
END LOOP;
END;
Statement processed.
1 - PACKAGE BODY pkg
2 - IS
3 - PROCEDURE insert_rows ( rows_in IN ibt )
4 - IS
5 - BEGIN
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
17 -
18 -
19 -
20 -
21 -
22 -
23 - /* Use the very cool INDICES OF feature to
24 - skip over gaps. */
25 - FORALL indx IN INDICES OF rows_in
26 - INSERT INTO t VALUES rows_in (indx);
27 -
28 - END insert_rows;
29 - END;