【问题标题】:How to send pl/sql procedure status through an email?如何通过电子邮件发送 pl/sql 程序状态?
【发布时间】:2021-10-19 17:47:41
【问题描述】:

我已经安排了一个 PL/SQL 过程。我想将 PL/SQL 过程的状态(无论是成功还是有任何错误消息)发送到我的电子邮件地址。

我看到了一些使用UTL_MAIL 发送预定义电子邮件模板的方法。但是如何将我的程序状态发送到电子邮件中?

【问题讨论】:

    标签: oracle plsql utl-mail


    【解决方案1】:

    在预定的存储过程结束时发送电子邮件,例如

    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;
    

    【讨论】:

      猜你喜欢
      • 2011-05-13
      • 1970-01-01
      • 2021-05-21
      • 2014-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 2016-11-21
      相关资源
      最近更新 更多