Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle Apex How to use Function returning sql query in IG

VinipandaMay 17 2021 — edited May 26 2021

Hi,
I had asked a question earlier in one of the threads.
The details are in thread here.
https://community.oracle.com/tech/developers/discussion/4484286/oracle-apex-modfiy-grid-query-to-fetch-previous-quarter-data-if-current-not-available#latest
Requirement was to write query for interactive grid that would return previous quarter data if current quarter was unavailable.
To resolve i created function in database returning sql which implements same logic. But i am not sure how to use it in apex application.
My current IG query is:

 SELECT DEPT_ID,DEPT_QUARTER_ID,
      ,KPI_1,KPI_2,KPI_3,KPI_4,KPI_5
  from DEPT_DATA
  WHERE  
    DEPT_QUARTER_ID=:DEPT_QUARTER_ID
  AND   PROJECT = :P1_PROJECT 

I need to modifiy this to use the function mentioned below retuning the sql .How can i do that?
As mentioned in thread, for project variable p_id, there is application item :PROJECT.
For year and quarter, i have app items A_YEAR AND A_QUARTER.
So function would be something like:
Q_VALUE(:A_YEAR,A_QUARTER, :PROJECT, :P1_DEPT --P1_DEPT is page item for departments
But how do i use this as source of IG?

Comments

Post Details

Added on May 17 2021
4 comments
5,501 views