在SELECT FROM TABLE(集合)中为全局集合类型的匿名列提供别名

问题描述 投票:1回答:1

我试图在apex_t_numbers查询中使用来自SELECT集合的值作为WITH子查询:

atn_cur_ids := apex_string.split_numbers(arg_v_ids, ':');
-- So if arg_v_ids := '1:2:3', then atn_cur_ids := apex_t_numbers(1, 2, 3)

with t_cur_ids as (
  select * as id from table(atn_cur_ids);
)
select text from t_texts 
join t_cur_ids on t_texts.id = t_cur_ids.id

这就是问题 - apex_t_numbersnumber的表,而不是带有命名字段的record类型。即使Oracle只有一个“匿名”列,Oracle SQL也不允许为*提供别名。

可能的解决方案可能是两者兼有的功能

  1. 收到*
  2. 返回每行的值

但我知道只有一个可以得到一个*并返回一些东西 - count(*),它不符合第二个要求。

plsql oracle11g user-defined-types oracle-apex-5.1
1个回答
1
投票

好的,找到了解决方案。它可以用column_value作为列的名称来完成:

with t_cur_ids as (
  select column_value as id from table(atn_cur_ids);
)
select text from t_texts 
join t_cur_ids on t_texts.id = t_cur_ids.id
© www.soinside.com 2019 - 2024. All rights reserved.