开发者

How to reference value from a drop down selection box ...?

开发者 https://www.devze.com 2023-04-10 14:50 出处:网络
I\'m using Oracle APEX and I\'m generating an interactive report .. Now I have a drop down selection box which has a list of 开发者_如何学运维values (LOVs) .. What I want to do is to use the currently

I'm using Oracle APEX and I'm generating an interactive report .. Now I have a drop down selection box which has a list of 开发者_如何学运维values (LOVs) .. What I want to do is to use the currently selected value in the drop down box in the SQL query being used to generate the interactive report .. Like for example this is the SQL query for generating the interactive report to only show employees with rank Salesman:

 select "EMP"."EMPNO" as "EMPNO",
        "EMP"."ENAME" as "ENAME",
        "EMP"."RANK" as "RANK",
 from   "EMP" "EMP" 
 where  "EMP"."RANK"  = 'SALESMAN'

The above query completely works for me ... Now I have a drop down box on the same page in APEX which is named RANKS, and has this LOV: SALESMAN, CLERK, ACCOUNTANT, DEPTHEAD

How do I change the SQL Query so that it now looks up the currently selected rank in the ranks drop down list and then only displays employees with that rank ...


If your ranks LOV is called P1_RANKS for example, then you can change the query SQL to:

select empno, ename, rank
from emp
where rank = :P1_RANKS

However, that only works once a rank has been selected. If you want to show all employees when no rank has been selected do this:

select empno, ename, rank
from emp
where (:P1_RANKS is null or rank = :P1_RANKS)

You can either make the select list submit the page to refresh the report or, preferably, create a dynamic action to refresh the report when the select list item is changed.

0

精彩评论

暂无评论...
验证码 换一张
取 消