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
Scheduling a report(s) from the database using APEX utility :
Till now using subscription, we can schedule the interactive report only.
Most cases we may get requirement to schedule the multiple reports with custom
definitions.
Here is the example to schedule a report from database using APEX utility.
Schduler :
BEGIN
dbms_scheduler.create_schedule(
schedule_name => 'Employee_Schedule',
start_date => trunc(sysdate),
repeat_interval => 'freq=Daily;Day='Mon',
comments => 'Runtime: Every Monday ');
END;
Program :
begin
-- Call a procedure
dbms_scheduler.create_program
(program_name=> 'Employee_Program',
program_type=> 'STORED_PROCEDURE',
program_action=> ?Employee? ,
enabled=>true,
comments=>'Procedure to collect session information'
);
end;
Job :
begin
-- Connect both dbms_scheduler parts by creating the final job
dbms_scheduler.create_job
(job_name => 'Employee_Job',
program_name=> 'Employee_Program',
schedule_name=>'Employee_Schedule',
enabled=>true,
auto_drop=>false,
comments=>'Job to collect data about session values every 5 minutes');
end;
Assume that you have successfully installed or upgrade your APEX, but when you tried to send an email, it's not working and you are able to see the above error in APEX_MAIL_QUEUE log.
Reason : The database user don't have a necessary permissions.
Below are some steps you need follow/check :
1. Run the below procedure as SYS user where APEX installed.
DECLARE ACL_PATH VARCHAR2(4000); BEGIN -- Look for the ACL currently assigned to '*' and give APEX_040200 -- the "connect" privilege if APEX_040200 does not have the privilege yet. SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL; IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_040200', 'connect') IS NULL THEN DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH, 'APEX_040200', TRUE, 'connect'); END IF; EXCEPTION -- When no ACL has been assigned to '*'. WHEN NO_DATA_FOUND THEN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml', 'ACL that lets power users to connect to everywhere', 'APEX_040200', TRUE, 'connect'); DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*'); END; / COMMIT; Above procedure will check the ACL's list and it will give the necessary permissions to the database user. NOTE : Need to change the database user according to your APEX version.
Oracle Application Express (Oracle APEX), formerly called HTML DB, is
a fully supported "no-cost" option of the Oracle Database. Oracle
Application Express is certified against all editions of the Oracle
Database 10.2.0.3 and above, including Oracle Database 10g Express
Edition (Oracle XE). Oracle Application Express installs as part of the seed database
installation with Oracle Database 11g. The latest version of Oracle
Application Express can be downloaded for free from the Oracle
Technology Network (OTN) [http://otn.oracle.com/apex]