Hello everyone,
I am trying to create a CSV file and then attach it to an email and send the email but I am receiving the following error: PLS-00201: identifier 'APEX_DATA_EXPORT.T_EXPORT' must be declared
Below is the code I am attempting to run:
declare
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
l_mail_id NUMBER;
l_workspace_id NUMBER;
name varchar2(225);
begin
select LNAME || '_' || FNAME || '_' || MNAME into name
from IN_PROCESSING
where :P23_PERS_ID = PERS_ID;
l_workspace_id := apex_util.find_security_group_id (p_workspace => 'OPERATIONS MANAGEMENT');
apex_util.set_security_group_id (p_security_group_id => l_workspace_id);
l_context := apex_exec.open_query_context (
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select i.EMPLOYEEID,
i.LNAME || '', '' || i.FNAME || '' '' || i.MNAME as NAME,
ASSIGNED_ORG,
PHONE_NUM,
(select p.LNAME || '', '' || p.FNAME || '' '' || p.MNAME from PERSONS p where i.SUPV = p.DISPLAY_NAME) as SUPERVISOR_NAME,
i.OFFICE_SYM,
i.POSITION_TYPE,
i.DUTY_TITLE || '' '' || i.RANK_GRADE as DUTY_TITLE_RANK_GRADE,
CYBERAWARE_DATE,
decode(i.GAIN_TYPE, ''Foreign National'', ''Yes'',NULL) as FOREIGN_NATIONAL,
COMPANY_NAME,
CONTR_NO,
CONTR_EXP_DATE
from IN_PROCESSING i
where PERS_ID = '||:P23_PERS_ID||';',
p_file_name => ''||name||'_test.csv');
l_export := apex_data_export.export (p_context => l_context, p_format => apex_data_export.c_format_csv);
apex_exec.close (l_context);
l_mail_id :=
APEX_MAIL.SEND (p_to => 'me@mail',
p_from => 'csv_test@us.af.mil',
p_body => 'words',
p_body_html => '<h2>Report is attached</h2>',
p_subj => 'Example Report');
APEX_MAIL.ADD_ATTACHMENT (p_mail_id => l_mail_id,
p_attachment => l_export.content_blob,
p_filename => ''||name||'_test.csv',
p_mime_type => 'text/csv');
apex_mail.push_queue;
end;
And below is the error received:
ORA-06550: line 3, column 17:
PLS-00201: identifier 'APEX_DATA_EXPORT.T_EXPORT' must be declared
ORA-06550: line 0, column 0:
PL/SQL: Compilation unit analysis terminated
ORA-06512: at "SYS.DBMS_SQL", line 1721
1. declare
2. l_context apex_exec.t_context;
3. l_export apex_data_export.t_export;
4. l_mail_id NUMBER;
5. l_workspace_id NUMBER;
Any assistance would be appreciated.
Thank you,
Derek
The APEX_DATA_EXPORT package was added in 20.2. If you're running version 20.1 of APEX this isn't available!
You'll need to upgrade APEX to use this approach.