-- 명시적 커서 사용
CREATE OR REPLACE PROCEDURE cursur_test
(
n_table IN varchar2
)
IS
i BINARY_INTEGER := 0;
j BINARY_INTEGER := 0;
TYPE table_idx IS TABLE OF ALL_IND_COLUMNS.index_name%TYPE
INDEX BY BINARY_INTEGER; -- index저장할 배열(테이블) 생성
table_owner varchar2(10); -- table 소유자
TYPE table_priv IS TABLE OF ALL_IND_COLUMNS.index_name%TYPE
INDEX BY BINARY_INTEGER; -- 소유자의 권한 조회
idx_list table_idx;
priv_list table_priv;
BEGIN
SELECT owner INTO table_owner FROM all_tables WHERE table_name LIKE n_table;
FOR idx IN
(
SELECT A.INDEX_NAME
FROM ALL_IND_COLUMNS A
WHERE A.TABLE_NAME = n_table AND index_owner = table_owner
) LOOP
i := i + 1;
idx_list(i) := idx.index_name;
END LOOP;
FOR cnt IN 1..i LOOP
DBMS_OUTPUT.PUT_LINE(idx_list(i));
END LOOP;
DBMS_OUTPUT.PUT_LINE(table_owner);
END;