Apex, Create page with dynamic table

Goal is to create a page with list of all tables in user tables, once you click on table display it on next page as classic report ( only with classic report this can be done)

  1. Create listing

2. Crate table view

Crate Clasic Report using PL/SQL

declare
 v_query varchar2(500);
 begin
    v_query := 'select * from DATA_USER.'||:P8_TABLE_NAME ;
 return v_query;
 end;

Important: Use Generic Column Name

To allow application APEX_APP_USER access to DATA_USER schema you need grant select access to APEX_APP_USER

grant SELECT on table DATA_USER.TABLE to APEX_APP_ROLE;
grant APEX_APP_ROLE to APEX_APP_USER;

Next step update Attiibutes

Change Headling to PL/SQL and use query

DECLARE
 vColumns VARCHAR2(4000);
 BEGIN
    SELECT LISTAGG(COLUMN_NAME, ':') WITHIN GROUP (ORDER BY COLUMN_ID) COLS
    into vColumns
   FROM ALL_TAB_COLUMNS
  WHERE OWNER='DATA_USER' 
    AND TABLE_NAME='TABLE';
 RETURN vColumns;
 END;

Leave a Reply

Your email address will not be published. Required fields are marked *