How do I get the index of VARRAY items after converting to a table

后端 未结 3 1715
粉色の甜心
粉色の甜心 2021-01-14 01:57

In the following example I create a VARRAY with 3 items.

TEST@XE> select t1, t2.* from
  2  (select \'X\' as t1 from dual UNION select \'Y\' from dual) t1         


        
3条回答
  •  一生所求
    2021-01-14 02:18

    I'm wondering why nobody came up with this, so I'm answering my own question

    select t1, t2.* from 
    (select 'X' as t1 from dual UNION select 'Y' from dual) t1, 
    (select ROWNUM rn, COLUMN_VALUE from table (sys.odcivarchar2list('a', 'b', 'c'))) t2
    
    T1          RN COLUMN_VALUE
    --- ---------- --------------------
    X            1 a
    X            2 b
    X            3 c
    Y            1 a
    Y            2 b
    Y            3 c
    

    The question remains however, whether this is actually guaranteed to work 100%

提交回复
热议问题