转换为表格后如何获取VARRAY项目的索引 [英] How do I get the index of VARRAY items after converting to a table
本文介绍了转换为表格后如何获取VARRAY项目的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的示例中,我创建了一个包含3个项目的VARRAY.
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 table (sys.odcivarchar2list('a', 'b', 'c')) t2;
T1 COLUMN_VALUE
--- --------------------
X a
X b
X c
Y a
Y b
Y c
我想要以下输出:
T1 INDEX COLUMN_VALUE
--- ----- --------------------
X 1 a
X 2 b
X 3 c
Y 1 a
Y 2 b
Y 3 c
请注意,sys.odcivarchar2list
被预定义为VARRAY(32767) OF VARCHAR2(4000);
.
推荐答案
select t1, row_number() over ( partition by t1 order by t1), t2.* from
(select 'X' as t1 from dual UNION select 'Y' from dual) t1,
table (sys.odcivarchar2list('a', 'b', 'c')) t2;
这篇关于转换为表格后如何获取VARRAY项目的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文