将Varray值作为串联文本列表
在db>> for oracle 18c中:
如果我选择一个varray,那么db> gt; tifddle返回一个空的结果集,这是误导的。
with data as (select sys.odcivarchar2list('a', 'b', 'c') as my_array from dual)
select my_array from data
Result:
MY_ARRAY
-------- [resultset is empty]
”
php's oci_fetch_all a href =“ https://www.orafaq.com/wiki/adt” rel =“ nofollow noreferrer”>抽象数据类型喜欢 sdo_geometry,我在日志中遇到这样的错误:
php警告:oci_fetch_all():ora-00932:不一致的数据类型:预期char获得了ADT PHP 警告:oci_fetch_all():ora-00932:不一致的数据类型:预期char获得了ADT
作为解决方法,我想以串联的文本列表(以SQL开发人员的工作方式)返回Varray的值。
像这样:
with data as (select sys.odcivarchar2list('a', 'b', 'c') as my_array from dual)
select varray_list(my_array) from data
-- ^^^ A fake function.
Result:
MY_ARRAY
--------
SYS.ODCIVARCHAR2LIST('a', 'b', 'c')
--or
'a', 'b', 'c'
--or
a,b,c
问题:
在查询中,有没有办法将Varray的值作为串联文本列表?
In db<>fiddle for Oracle 18c:
If I select a varray, then db<>fiddle returns an empty resultset, which is misleading.
with data as (select sys.odcivarchar2list('a', 'b', 'c') as my_array from dual)
select my_array from data
Result:
MY_ARRAY
-------- [resultset is empty]
@JackDouglas said this in a related post:
PHP’s oci_fetch_all doesn’t like abstract data types like
SDO_GEOMETRY, I’m getting errors like this in the logs:PHP Warning: oci_fetch_all(): ORA-00932: inconsistent datatypes: expected CHAR got ADT PHP Warning: oci_fetch_all(): ORA-00932: inconsistent datatypes: expected CHAR got ADT
As a workaround, I want to return the varray's values as a concatenated text list (the same way it works in SQL Developer).
Like this:
with data as (select sys.odcivarchar2list('a', 'b', 'c') as my_array from dual)
select varray_list(my_array) from data
-- ^^^ A fake function.
Result:
MY_ARRAY
--------
SYS.ODCIVARCHAR2LIST('a', 'b', 'c')
--or
'a', 'b', 'c'
--or
a,b,c
Question:
In a query, is there a way to get a varray's values as a concatenated text list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
横向
加入表收集表达式,然后使用ListAgg
:输出:
或,如果您想要周围的引号:
输出:
db&lt;&gt; fiddle
LATERAL
join a table collection expression and then useLISTAGG
:Which outputs:
or, if you want the surrounding quotes:
Which outputs:
db<>fiddle here