Current version of APEX does not have the option for function returning SQL query when we use interactive report as report type
.
Below is the work around for that.
1. Create a function in the database.
Ex :
CREATE OR REPLACE FUNCTION IR_COLLECTION_FUN RETURN CLOB AS
V_QUERY CLOB;
BEGIN
V_QUERY := 'SELECT * FROM EMP';
RETURN (V_QUERY);
END;
2. Create a page and add the below process to your page
Process Point : On load before header
3. Create a report that querying from the collection
select * from apex_collection where collection_name = 'IR';
4. As we are using collection, header names will be cxx...
Hide all the unnecessary columns.
For header names create hidden items.
5. Create a process to populate the header names as below
select
'empno',
'ename',
'job',
'mgr',
'hiredate',
'sal',
'comm',
'deptno'
into
:P3_COL1,
:P3_COL2,
:P3_COL3,
:P3_COL4,
:P3_COL5,
:P3_COL6,
:P3_COL7,
:P3_COL8
from dual;
6. In column attributes heading add the hidden item names as below
7. Final report as below
Working example : http://apex.oracle.com/pls/apex/f?p=43578:3
.
Below is the work around for that.
1. Create a function in the database.
Ex :
CREATE OR REPLACE FUNCTION IR_COLLECTION_FUN RETURN CLOB AS
V_QUERY CLOB;
BEGIN
V_QUERY := 'SELECT * FROM EMP';
RETURN (V_QUERY);
END;
2. Create a page and add the below process to your page
Process Point : On load before header
3. Create a report that querying from the collection
select * from apex_collection where collection_name = 'IR';
4. As we are using collection, header names will be cxx...
Hide all the unnecessary columns.
For header names create hidden items.
5. Create a process to populate the header names as below
select
'empno',
'ename',
'job',
'mgr',
'hiredate',
'sal',
'comm',
'deptno'
into
:P3_COL1,
:P3_COL2,
:P3_COL3,
:P3_COL4,
:P3_COL5,
:P3_COL6,
:P3_COL7,
:P3_COL8
from dual;
6. In column attributes heading add the hidden item names as below
7. Final report as below
Working example : http://apex.oracle.com/pls/apex/f?p=43578:3




