多选LOV显示

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

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

示例: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

oracle-apex oracle11gr2
1个回答
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>
© www.soinside.com 2019 - 2024. All rights reserved.