develog

[Oracle] REF CURSOR 본문

DB/Oracle

[Oracle] REF CURSOR

냐옴 2015. 6. 18. 16:55

DECLARE

    TYPE T_LIST IS TABLE OF VARCHAR2(20);
    V_LIST        T_LIST;

    TYPE T_CURSOR IS REF CURSOR;
    V_CURSOR    T_CURSOR;
    V_SQL        VARCHAR2(100);

BEGIN

    V_SQL := '
        SELECT TITLE
        FROM ATEST
        WHERE SEQ IN (1,2,3)
    ';

    OPEN V_CURSOR FOR V_SQL;
    FETCH V_CURSOR BULK COLLECT INTO V_LIST;
    CLOSE V_CURSOR;

    FOR I IN 1..V_LIST.COUNT
    LOOP
        DBMS_OUTPUT.PUT_LINE(V_LIST(I));
    END LOOP;

END;


'DB > Oracle' 카테고리의 다른 글

[Oracle] time zone  (0) 2015.08.04
[Oracle] Trigger 생성  (0) 2015.06.19
[Oracle] DDL, DML, DCL, TCL  (0) 2015.05.13
[Oracle] 부여된 권한 조회  (0) 2015.01.21
[Oracle] GRANT 조회  (0) 2015.01.13
Comments