在交互式报表列上显示多个显示值,其中包含基于LOV的多个值(清单)

时间:2018-01-19 21:06:22

标签: oracle oracle-apex

我想在列中显示显示值,但该列是一个字符串,其条目如“1:3”,“2”,“1:2:4”,这些是基于LOV的返回值具有静态值。

如果我将列设置为“显示文本(基于LOV)”,则它仅适用于仅包含一个数字的条目,如“3”或“1”。

我想过规范化表格,但后来我会有一个多表格形式。 这应该很简单,但我无法弄清楚如何做到这一点?

    select p.COD,
          UNIDADE_PROPONENTE,
          CAUSA_FUND,
          CAUSAS_RELAC,
          TITULO,
          DESC_SOLUC,
          listagg(a.acao, ';<br><br>') within group (order by null)  as "a.acao",    
          OUTRA_ACAO,
          SUGESTAO,
          SITUACAO
      from TB_PROPOSTA p, TB_ACAO a,
      table(cast(multiset(select level from dual
                            connect by level <=regexp_count(p.acao,':') + 1)
                            as sys.odcinumberlist)) x

      where 
        a.cod = regexp_substr(p.acao, '[^:]+', 1, x.column_value)
        and
        (:P2_XUNIDADE_RESPONSAVEL = UNIDADE_PROPONENTE OR :P2_XUNIDADE_RESPONSAVEL IS NULL)
        and   
        (INSTR(':'|| p.acao ||':', ':' || :P2_XACAO || ':') > 0 OR :P2_XACAO IS NULL)
    group by p.cod, p.acao, unidade_proponente, causa_fund, causas_relac, titulo, desc_soluc, outra_acao, sugestao, situacao
    order by p.cod, p.acao;

编辑: 现在我要么丢失关键字错误,要么sql命令没有正确结束。 这个给出了SQL COMMAND NOT PROPERLY ENDED

select p.COD,
       UNIDADE_PROPONENTE,
       CAUSA_FUND,
       CAUSAS_RELAC,
       TITULO,
       DESC_SOLUC,  
       listagg(a.acao, ';<br><br>') within group (order by null) as "a.acao",    
       OUTRA_ACAO,
       SUGESTAO,
       SITUACAO
  from TB_PROPOSTA p
  cross join table(cast(multiset(select level from dual
                        connect by level <=regexp_count(p.acao,':') + 1)
                        as sys.odcinumberlist)) x
  left join TB_ACAO.ACAO  

on TB_ACAO.COD = regexp_substr(TB_PROPOSTA.ACAO, '[^:]+', 1, x.column_value) 

    where
        (:P2_XUNIDADE_RESPONSAVEL )= UNIDADE_PROPONENTE OR :P2_XUNIDADE_RESPONSAVEL IS NULL)
        AND
        (:P2_XACAO IN (p.ACAO) OR :P2_XACAO IS NULL)
    group by p.cod, p.acao, unidade_proponente, causa_fund, causas_relac, titulo, desc_soluc, outra_acao, sugestao, situacao
    order by p.cod, p.acao;

如果我将“交叉连接”更改为“加入”,我会在“where”

1 个答案:

答案 0 :(得分:0)

感谢您提供其他解释。

这样的事情有帮助吗?我的TEST表充当您的报表查询,而其余部分则分割冒号分隔的值。这是一个SQL * Plus示例,只是为了向您展示正在发生的事情。

SQL> with test (situacao, tipo_acao) as
  2  (select 'Aguardando resposta', '1:2:3' from dual union
  3   select 'Aguardando resposta', '5' from dual
  4  )
  5  select
  6    situacao,
  7    'This is value ' || regexp_substr(tipo_acao, '[^:]+', 1, column_value) tipo_acao
  8  from test,
  9    table(cast(multiset(select level from dual
 10                        connect by level <= regexp_count(tipo_acao, ':') + 1)
 11                        as sys.odcinumberlist));

SITUACAO            TIPO_ACAO
------------------- ----------------------------------
Aguardando resposta This is value 1
Aguardando resposta This is value 2
Aguardando resposta This is value 3
Aguardando resposta This is value 5

SQL>

[在您的Apex应用程序中创建第5页后编辑]

我想我明白了 - 看看第5页(创建为第2页的副本,这样我就不会破坏它)。它的列列表减少了,但你会得到一般的想法。查询看起来像这样;我希望没关系:

select p.cod,
       s.situacao,
       p.tipo_acao,
       listagg(t.acao, ', ') within group (order by null) acao
from tb_proposta p,
     tipo_situacao s,
     vw_unid v,
     tipo_acao t,
     table(cast(multiset(select level from dual
                         connect by level <= regexp_count(p.tipo_acao, ':') + 1)
                         as sys.odcinumberlist)) x
where s.cod = p.proposta_status
  and p.cod_vw_unid = v.cod
  and t.cod= regexp_substr(p.tipo_acao, '[^:]+', 1, x.column_value)
group by p.cod, s.situacao, p.tipo_acao
order by p.cod, p.tipo_acao;

[编辑#2,ANSI外部联接]

这是你应该尝试的方法。此外,CROSS JOIN及其在查询中的位置。

select p.cod,
       s.situacao,
       p.tipo_acao,
       listagg(t.acao, ', ') within group (order by null) acao
from tb_proposta p
cross join table(cast(multiset(select level from dual
                               connect by level <= regexp_count(p.tipo_acao, ':') + 1)
                               as sys.odcinumberlist)) x 
      join tipo_situacao s   on s.cod = p.proposta_status
      join vw_unid v         on v.cod = p.cod_vw_unid
left  join tipo_acao t  on t.cod = regexp_substr(p.tipo_acao, '[^:]+', 1, x.column_value)
group by p.cod, s.situacao, p.tipo_acao
order by p.cod, p.tipo_acao;