oracle-apex

Oracle APEX Select Many page item with a Query for a bar chart


I have a basic bar chart that I'm trying to add a name filter for which works for a single selection, but I'm trying to use a Select Many page item with an in clause and it doesnt work.

Here is my where clause for the chart.

APEX_USER = :APP_USER 
and EMP_NAME in :P4_FILTER
and CREATED_DATE_TIME > to_date(:P4_START_D,'MM/DD/YYYY')
and CREATED_DATE_TIME < to_date(:P4_END_D,'MM/DD/YYYY')

And when I select a single user from the p4_filter it works fine.

And I added the delimitted list separator to be comma.

del

Thanks for any help.


Solution

  • Try this:

    APEX_USER = :APP_USER 
    and EMP_NAME in (select * from table(apex_string.split(:P4_FILTER,',')))
    and CREATED_DATE_TIME > to_date(:P4_START_D,'MM/DD/YYYY')
    and CREATED_DATE_TIME < to_date(:P4_END_D,'MM/DD/YYYY')
    

    The issue arises when you want to use a comma-separated string as a parameter in an IN clause within your SQL query. For example, you might have a string like '102,103,104' representing student IDs, and you want to retrieve records for those specific students.

    The Problem is that when you directly use the comma-separated string in the IN clause, it is treated as a single value.Instead of checking each individual value (e.g., ‘102’, ‘103’, ‘104’), the query treats the entire string (‘102,103,104’) as one value. As a result, you won’t get the desired results.