SELECT into with varray column : VARRAY Column « Collections « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE OR REPLACE TYPE numberVarryType AS VARRAY(10)OF NUMBER(10);
  2  /

Type created.

SQL>
SQL> CREATE TABLE address_list (
  2      list_id VARCHAR2(6)PRIMARY KEY,
  3      direct_addresses numberVarryType
  4  );

Table created.

SQL>
SQL>
SQL> DECLARE
  2    v_add_varray address_list.direct_addresses%TYPE;
  3  BEGIN
  4    SELECT direct_addresses INTO v_add_varray FROM address_list WHERE list_id ='OFF101';
  5
  6    FOR idx IN 1..v_add_varray.COUNT LOOP
  7      DBMS_OUTPUT.PUT_LINE(TO_CHAR(v_add_varray(idx)));
  8    END LOOP;
  9  EXCEPTION WHEN OTHERS THEN
 10    DBMS_OUTPUT.PUT_LINE(SQLERRM);
 11  END;
 12  /
ORA-01403: no data found

PL/SQL procedure successfully completed.

SQL>
SQL> drop table address_list;

Table dropped.








26.3.VARRAY Column
26.3.1.Stored VARRAYS
26.3.2.Using a Varray Type to Define a Column in a Table
26.3.3.Display the structure of a table with a valarray column
26.3.4.Populating a Varray with Elements
26.3.5.Selecting Varray Elements
26.3.6.Modifying Varray Elements
26.3.7.Set empty varray value
26.3.8.Define function to get the first value in varray
26.3.9.Insert on whole VARRAYS
26.3.10.UPDATE on varray column in PL/SQL block
26.3.11.UPDATE on varray column
26.3.12.DELETE on varray column
26.3.13.SELECT into with varray column