我已经安排了一个 PL/SQL 过程。我想将 PL/SQL 过程的状态(无论是成功还是有任何错误消息)发送到我的电子邮件地址。
我看到了一些使用UTL_MAIL
. 但是我怎样才能将我的程序状态发送到电子邮件中?
在预定的存储过程结束时发送电子邮件,例如
create or replace procedure p_your_proc as
l_error varchar2(300);
begin
-- do some processing
-- if there were no errors
utl_mail.send(sender => 'rosh@gmail.com',
recipients => 'rosh@gmail.com',
cc => null,
bcc => null,
subject => 'Procedure P_YOUR_PROC completed successfully',
message => null);
exception
when others then
l_error := sqlerrm;
utl_mail.send(sender => 'rosh@gmail.com',
recipients => 'rosh@gmail.com',
cc => null,
bcc => null,
subject => 'Procedure P_YOUR_PROC ended with an error',
message => l_error);
raise;
end;