使用复选框选中的元素来过滤报告

时间:2018-06-21 08:42:51

标签: plsql oracle-apex-5

我无法为自己的申请做出正确的报告。该报告应返回具有一组参数(包括设备列表)的免费房间。但是,我无法在互动报告中包括装备搜索。

这是我收到的SQL请求:

SELECT s.code || ' ' || s.nom as Salle, s.capacite, LISTAGG(eq.libelle, ', ') WITHIN GROUP (ORDER BY eq.code) as Equipements, b.libelle as Batiment, s.numero
FROM SALLES s
INNER JOIN batiments b ON
b.numero = s.bat_numero
INNER JOIN sal_gpe sg ON
s.numero = sg.sal_numero
INNER JOIN groupespersonnes gp ON
gp.numero = sg.gpe_numero
LEFT JOIN equ_sal e ON
e.sal_numero = s.numero
LEFT JOIN equipements eq ON 
eq.numero = e.equ_numero

-- On vérifie les salles visibles pour le groupe de personne affecté à l'utilisateur connecté. 
WHERE gp.code = (SELECT code FROM groupespersonnes INNER JOIN personnes p ON p.gpe_numero = groupespersonnes.numero WHERE UPPER(:APP_USER) = UPPER(p.username))

AND :P30_PERIODE_DEBUT NOT IN (SELECT per_numero FROM enregistrements WHERE sal_numero = s.numero AND TO_CHAR(jour, 'DD.MM.RR') = :P30_DATE)
AND :P30_PERIODE_FIN NOT IN (SELECT per_numero FROM enregistrements WHERE sal_numero = s.numero AND TO_CHAR(jour, 'DD.MM.RR') = :P30_DATE)

AND e.equ_numero = regexp_substr(:P30_EQUIPEMENTS,'[^:]+')
GROUP BY s.capacite, s.nom, b.libelle, s.numero, s.code

我正在对设备进行LISTAGG,以便我可以显示一个房间中一个房间的所有设备。现在:P30_EQUIPEMENT实际上是一个STRING。它采用从复选框列表中选择的设备数量(动态LOV),并用“:”分隔。我一直在尝试许多解决方案,但没有任何效果。我现在在使用PL / SQL选项。

如果您有一种更简单的方法的想法,我很乐意接受。

1 个答案:

答案 0 :(得分:0)

如果:P30_EQUIPMENTS包含此内容,则您应该:

SQL> with test (p30_equipments) as
  2    (select 'tv:balcony:shower' from dual)
  3  select regexp_substr(p30_equipments, '[^:]+', 1, level) equipment
  4  from test
  5  connect by level <= regexp_count(p30_equipments, ':') + 1;

EQUIPMENT
-----------------
tv
balcony
shower

SQL>

即应用于您的代码:

and e.equ_numero in (select regexp_substr(:p30_equipments, '[^:]+', 1, level)
                     from dual
                     connect by level <= regexp_count(:p30_equipments, ':') + 1
                    )