Construct a null element nested table type in the database, then extends it one element at a time. : Varchar Table « PL SQL « Oracle PL / SQL






Construct a null element nested table type in the database, then extends it one element at a time.

 
SQL> SET ECHO ON
SQL> SET SERVEROUTPUT ON SIZE 1000000
SQL>
SQL> 
SQL> CREATE OR REPLACE TYPE charArrayType
  2    AS TABLE OF VARCHAR2(5 CHAR);
  3  /

Type created.

SQL>
SQL> DECLARE
  2
  3    
  4    charArray charArrayType := charArrayType(NULL,NULL,NULL);
  5
  6  BEGIN
  7    FOR i IN 1..3 LOOP
  8      dbms_output.put     ('charArray Varray:'||i);
  9      dbms_output.put_line(','||charArray(i));
 10
 11    END LOOP;
 12    charArray(1) := 'Ace';
 13    charArray(2) := 'Two';
 14    charArray(3) := 'Three';
 15
 16    FOR i IN 1..3 LOOP
 17      dbms_output.put_line('charArray :'||i||', '||charArray(i));
 18    END LOOP;
 19
 20  END;
 21  /
charArray Varray:1,
charArray Varray:2,
charArray Varray:3,
charArray :1, Ace
charArray :2, Two
charArray :3, Three

PL/SQL procedure successfully completed.

SQL>

   
  








Related examples in the same category

1.Table of varchar2: first, next and last
2.Reference varchar table by index
3.table of varchar2(200) index by binary_integer