多选LOV显示

时间:2017-12-18 22:23:53

标签: oracle-apex oracle11gr2

所以,我正在努力解决这个问题。我目前正在使用多选列表来捕获和存储数据库中的值(冒号分隔)。

示例:A:S:O

我想使用动态LOV将这些值转换为更有意义的值,例如:

Auto, Student, Other

但是,我不确定如何解决这个问题。我熟悉动态LOV,但我如何按不同的顺序处理各种组合?

我是否被迫使用apex_item并循环播放数组?我可以以某种方式利用listagg和/或connect by声明吗?

我有一个密钥表,其中KEY_NAME存储密钥(即a,s,o等),KEY_LABEL存储相应的翻译。

APEX 4.2 - oracle 11gr2

1 个答案:

答案 0 :(得分:0)

我不确定KEY_NAME表的用途是什么?如果它只包含一列(a,s,o,...),则KEY_LABEL(在这种情况下,必须包含具有相应描述的ID)应该足够了。

无论如何:这样的事情会有什么好处吗?

SQL> with key_label (id, name) as
  2    -- sample labels
  3    (select 'a', 'auto' from dual union
  4     select 's', 'student' from dual union
  5     select 'o', 'other' from dual union
  6     select 'm', 'moto' from dual
  7    ),
  8  lov (value) as
  9    -- this is your LoV value
 10    (select 'a:o:s' from dual
 11    ),
 12  ones as
 13    -- LoV value transformed into rows
 14    (select regexp_substr(l.value, '[^:]+', 1, level) id
 15     from lov l
 16     connect by level <= regexp_count(l.value, '[^:]+')
 17    )
 18  -- final result (join Lov, as rows, with labels
 19  select listagg(k.name, ':') within group (order by r.id) result
 20  from key_label k, ones r
 21  where k.id = r.id;

RESULT
---------------------------------------------------------------------
auto:other:student

SQL>
相关问题