假设我有两个文件名相同的文件sample.xlsx
在两个单独的目录u1\data\out1\
和u2\data\out2\
中
这两个目录已分别作为DBA_DIRECTORIES
和EXT_OUT1
分配到EXT_OUT2
。
我想使用sample.xlsx
从EXT_OUT1
发送UTL_MAIL.SEND_ATTACH_RAW
,
如何将其正确传递给attachment
参数?
示例匿名阻止(注释注释):
DECLARE
vInHandle utl_file.file_type;
l_sender varchar2(100) := 'SO@SO.com';
l_recipients varchar2(100) := 'migs.isip.23@gmail.com';
l_subject varchar2(100) := 'Employee Roster Report';
l_message varchar2(100) := 'Hello';
l_attachment raw;
l_directory varchar2(100) := 'EXT_OUT1';
fname varchar2(100) := 'sample.xlsx';
BEGIN
/* how put RAW data into l_attachment here? */
--vInHandle := utl_file.fopen(l_directory, fname, 'R'); -- If i'm not mistaken, this reads the File from the specified directory
--utl_file.get_raw(); -- not sure what parameters i should pass
--utl_file.fclose(vInHandle); -- ?
UTL_MAIL.SEND_ATTACH_RAW
(
sender => l_sender
, recipients => l_recipients
, subject => l_subject
, message => l_message
, attachment => l_attachment
, att_filename => 'clouds.jpg'
);
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'The following error has occured: ' || sqlerrm);
END;
答案 0 :(得分:0)
附件内容是您作为附件参数提供的值。文件名只是一个标签。它不会读取文件,因此您必须自己执行此操作,然后将其指定为附件。