|
|
|
|
|
Re: Help needed regarding collect function [message #379585 is a reply to message #379499] |
Wed, 07 January 2009 02:56   |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Kevin Meade wrote on Tue, 06 January 2009 15:05 | Since COLLECT currently works only on a single column, some might say it is of little to no use.
|
That one column can be an object that contains multiple columns:
SCOTT@orcl_11g> create or replace type test_cols_typ as object
2 (col1 varchar2(15),
3 col2 varchar2(15));
4 /
Type created.
SCOTT@orcl_11g> create or replace type test_cols_tab as table of test_cols_typ;
2 /
Type created.
SCOTT@orcl_11g> select cast (collect (test_cols_typ (dname, loc)) as test_cols_tab)
2 from dept
3 /
CAST(COLLECT(TEST_COLS_TYP(DNAME,LOC))ASTEST_COLS_TAB)(COL1, COL2)
--------------------------------------------------------------------------------
TEST_COLS_TAB(TEST_COLS_TYP('ACCOUNTING', 'NEW YORK'), TEST_COLS_TYP('RESEARCH',
'DALLAS'), TEST_COLS_TYP('SALES', 'CHICAGO'), TEST_COLS_TYP('OPERATIONS', 'BOST
ON'))
SCOTT@orcl_11g>
|
|
|
|