如何通过邮件发送pl/sql过程状态?



我已经安排了一个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;

最新更新