ITPub博客

首页 > 数据库 > 数据库开发技术 > send mail using PL/SQL and the database trigger monitoring the error

send mail using PL/SQL and the database trigger monitoring the error

原创 数据库开发技术 作者:ORAnothing 时间:2007-01-12 09:08:50 0 删除 编辑

I think it's useful, later, i will enhance it

[@more@]

CREATE OR REPLACE PROCEDURE send_mail (
pSender VARCHAR2,
pRecipient VARCHAR2,
pSubject VARCHAR2,
pMessage VARCHAR2) IS

mailhost CONSTANT VARCHAR2(30) := 'wzccb.com';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
mesg VARCHAR2(1000);
mail_conn utl_smtp.connection;

BEGIN
mail_conn := utl_smtp.open_connection(mailhost, 25);

mesg := 'Date: ' ||
TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss') || crlf ||
'From: <'|| pSender ||'>' || crlf ||
'Subject: '|| pSubject || crlf ||
'To: '||pRecipient || crlf || '' || crlf || pMessage;

utl_smtp.helo(mail_conn, mailhost);
utl_smtp.mail(mail_conn, pSender);
utl_smtp.rcpt(mail_conn, pRecipient);
utl_smtp.data(mail_conn, mesg);
utl_smtp.quit(mail_conn);
END send_mail;
/

create or replace trigger test_sun
after servererror on database
declare
ora_server_error_msg varchar2(1000) ;
begin
ora_server_error_msg := SQLERRM(-ora_server_error(1)) ;
dbms_output.put_line(ora_server_error_msg) ;
end ;
/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8217470/viewspace-889957/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    1
  • 访问量
    1754