Retrieving Elements from a Varray
CREATE TYPE t_varray AS VARRAY(3) OF VARCHAR2(50);
/
CREATE TABLE emp(
id INTEGER PRIMARY KEY,
first_name VARCHAR2(10),
last_name VARCHAR2(10),
addresses t_varray
);
INSERT INTO emp VALUES (1, 'Jason', 'Bond',t_varray_address('Main Street, small town, CA, 12345',
'Second Street, middle town, CA, 54321'
)
);
SQL> SELECT *
2 FROM emp
3 WHERE id = 1;
ID FIRST_NAME LAST_NAME ADDRESSES
---------- ---------- -----------------------------------------
1 Jason Bond T_VARRAY('Main Street, small town, CA, 12345', 'Second Street, middle town, CA,54321')
SQL>
The next query specifies the actual column names:
SQL> SELECT id, first_name, last_name, addresses
2 FROM emp
3 WHERE id = 1;
ID FIRST_NAME LAST_NAME ADDRESSES
---------- ---------- ----------------------------------------
1 Jason Bond T_VARRAY('Main Street, small town, CA, 12345', 'Second Street, middle town, CA,54321')
SQL>
Home »
Oracle »
PL/SQL »
Oracle »
PL/SQL »
Varrays:
- Creating a Varray Type
- Using a Varray Type to Define a Column
- Getting Information on a Varray
- Populating a Varray with Elements
- Retrieving Elements from a Varray
- Using TABLE() to Treat a VArrays
- Modifying Elements of a Varray
Related: