I need to create an interactive report but instead of running a sql statement I need to run a pl/sql statement
-----------------------------------------------------------------------------
USER_ID Name 1 java 2 php 3 pl/sql / sql 4 Oracle apex
-------------- -------------------- ------ ----- -------------- -------------
3 Amy brown N N Y N
4 Sarah woods N N Y Y
2 Johnny paterson Y Y Y Y
1 John brown Y N Y Y
If this is NOT possible to do in apex, Is there any way of saving the results from that pl/sql statement in a csv format when you run the pl/sql?
In the interactive report, users will not be able to add or remove anything. Its is only for viewing.
Thanks
As Scott had stated, one option is to create an APEX collection with the refcursor, then create an interactive grid off of the data using the APEX_COLLECTIONS view. I have built an example to demonstrate this.
Create a Pre-Rendering Process at the point Before Header. Using this method, you can add additional logic to not re-populate the data if the collection already exists or so the data is not refreshed every time a user refreshes their page.
Set up of Pre-Rendering Process
Source code of populating the collection:
DECLARE
l_ref_cur SYS_REFCURSOR;
TYPE user_skill_rec IS RECORD
(
user_id NUMBER,
name VARCHAR2 (100),
java VARCHAR2 (1),
php VARCHAR2 (1),
plsql_sql VARCHAR2 (1),
oracle_apex VARCHAR2 (1)
);
l_user_skill user_skill_rec;
FUNCTION get_ref_cursor
RETURN SYS_REFCURSOR
IS
l_cur SYS_REFCURSOR;
BEGIN
OPEN l_cur FOR
SELECT 3 AS user_id,
'Amy brown' AS name,
'N' AS java,
'N' AS php,
'Y' AS plsql_sql,
'N' AS oracle_apex
FROM DUAL
UNION ALL
SELECT 4 AS user_id, 'Sarah woods', 'N', 'N', 'Y', 'Y' FROM DUAL
UNION ALL
SELECT 2 AS user_id, 'Johnny paterson', 'Y', 'Y', 'Y', 'Y' FROM DUAL
UNION ALL
SELECT 1 AS user_id, 'John brown', 'Y', 'N', 'Y', 'Y' FROM DUAL;
RETURN l_cur;
END;
BEGIN
l_ref_cur := get_ref_cursor;
apex_collection.create_or_truncate_collection ('USER_SKILLS');
LOOP
FETCH l_ref_cur INTO l_user_skill;
EXIT WHEN l_ref_cur%NOTFOUND;
apex_collection.add_member (p_collection_name => 'USER_SKILLS',
p_n001 => l_user_skill.user_id,
p_c001 => l_user_skill.name,
p_c002 => l_user_skill.java,
p_c003 => l_user_skill.php,
p_c004 => l_user_skill.plsql_sql,
p_c005 => l_user_skill.oracle_apex);
END LOOP;
END;
Then, just create your Interactive Report querying the APEX_COLLECTIONS view with the same collection that had the data populated:
Setup of Interactive Report
Source Query:
select n001, c001, c002, c003, c004, c005
from apex_collections
where collection_name = 'USER_SKILLS'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With