代码之家  ›  专栏  ›  技术社区  ›  VELFR

在“从表(集合)”中为全局集合类型的匿名列提供别名

  •  0
  • VELFR  · 技术社区  · 6 年前

    我试图使用 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
    

    这就是问题所在- 顶点数 是一张桌子 number 而不是 record 使用命名字段键入。Oracle SQL不允许为 * 即使只有一个“匿名”栏。

    一个可能的解决方案是

    1. 接收 *
    2. 每行返回值

    但我知道只有一个 * 还有些东西- count(*) ,不满足第二个要求。

    0 回复  |  直到 6 年前
        1
  •  1
  •   VELFR    6 年前

    好吧,找到解决办法。这可以用 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