在Oracle中发送非常大的HTML消息正文

时间:2018-11-03 13:33:35

标签: sql oracle oracle12c

我下面有一段代码-

declare
msg clob;
begin
select email into msg from ANI_CLOB;
Utl_Mail.Send(Sender =>'<abc.def@xyz.com>', Recipients =>abc.def@xyz.com,subject =>'CLOB MESSAGE', MIME_TYPE => 'text/html', Message =>msg);
end;

表ANI_CLOB的一列“ EMAIL”具有CLOB数据类型,只有一行存储大的html电子邮件正文。

运行此代码块时,我遇到错误-

Error report -
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 5
06502. 00000 -  "PL/SQL: numeric or value error%s"
*Cause:    An arithmetic, numeric, string, conversion, or constraint error
           occurred. For example, this error occurs if an attempt is made to
           assign the value NULL to a variable declared NOT NULL, or if an
           attempt is made to assign an integer larger than 99 to a variable
           declared NUMBER(2).
*Action:   Change the data, how it is manipulated, or how it is declared so
           that values do not violate constraints.

我们能否在utl_mail.send中将CLOB作为消息正文发送。 另外,我只想将此消息作为邮件正文发送。

1 个答案:

答案 0 :(得分:0)

否,UTL_MAIL不支持CLOBs。如果必须执行此操作,则必须使用UTL_SMTP,自己处理与邮件服务器通信的不同步骤,并通过多次调用CLOB发送utl_smtp.write_data