首页 > 解决方案 > 在 Oracle 中发送非常大的 HTML 消息正文

问题描述

我有以下代码-

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 有一列具有 CLOB 数据类型的“EMAIL”,并且只有一行存储大型 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 作为消息体发送吗?另外,我只想将此消息作为邮件正文发送。

标签: sqloracleoracle12c

解决方案


不,UTL_MAIL不支持CLOBs。如果你必须这样做,你将不得不使用UTL_SMTP,自己处理与邮件服务器通信的不同步骤,并将CLOB使用多个调用发送到utl_smtp.write_data


推荐阅读