Thursday, January 16, 2020

Oracle nested collection test code

set SERVEROUT ON;
DECLARE

TYPE VARCHAR_TABLE IS TABLE OF VARCHAR2(64);
TYPE VC_VARCHAR_TABLE IS TABLE OF VARCHAR_TABLE INDEX BY VARCHAR2(64);

v_t1 VARCHAR_TABLE := VARCHAR_TABLE ('abc1','abc2','abc3');
v_t2 VARCHAR_TABLE := VARCHAR_TABLE();

v_t3 VC_VARCHAR_TABLE;

BEGIN
    v_t2.EXTEND(4);
    v_t2(1) := 'test1';
    v_t2(2) := 'test2';
    v_t2(3) := 'test3';
   
    DBMS_OUTPUT.PUT_LINE('VALUE in v_t1 3 is ' || v_t1(3));
    DBMS_OUTPUT.PUT_LINE('VALUE in v_t2 3 is ' || v_t2(3));
   
    v_t3('a1') := v_t1;
    v_t3('a2') := v_t2;
   
    DBMS_OUTPUT.PUT_LINE('VALUE in v_t3 2 is ' || v_t3('a2')(2));
   
END;
/



-----------------------------------------------------------------------------------------

VALUE in v_t1 3 is abc3
VALUE in v_t2 3 is test3
VALUE in v_t3 2 is test2


PL/SQL procedure successfully completed.

No comments:

Post a Comment