PL/SQL 过程中的以下代码检查字节大小,如果它超过 30000 字节,它会迭代数据并
为每 30000 字节(30 kb)发送邮件附件(通过多个邮件的 txt 文件)。
我需要在单个邮件中获取整个文件,该邮件在 oracle PL/SQL 中大小为 4 mb。
lv_message_tab 的数据类型是 varchar2(32767) 。我可以使用CLOB数据类型而不是 * Varchar2(32767), * 如果是,请建议如何使用。
提前一百万谢谢!!!
FOR lv_idx in 1..pv_message.COUNT
LOOP
lv_message := lv_message||pv_message(lv_idx)|| lv_cr;
IF LENGTH(lv_message) >= 30000
THEN
lv_message_tab.EXTEND;
lv_message_tab(lv_message_tab.LAST) := lv_message;
lv_message := null;
END IF;
END LOOP;
--This send the attachment for 30000 characters and above
IF lv_message_tab.COUNT > 0
THEN
FOR lv_idx in 1..lv_message_tab.COUNT
LOOP
UTL_SMTP.HELO(lv_conn, lv_smtp_host);
UTL_SMTP.MAIL(lv_conn, gc_sender);
UTL_SMTP.RCPT(lv_conn, lv_to_email_ids);
UTL_SMTP.RCPT(lv_conn, lv_cc_email_ids);
UTL_SMTP.DATA(lv_conn,
'Date: ' || TO_CHAR(SYSDATE, gc_dd_month_yyyy_format) || lv_cr ||
'From: ' || gc_sender || lv_cr ||
'Subject: '|| lv_subject || lv_cr ||
'To: ' || lv_to_email_ids || lv_cr ||
'CC: ' || lv_cc_email_ids || lv_cr ||
'MIME-Version: 1.0'|| lv_cr || -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| lv_cr ||
' boundary="-----SECBOUND"'|| lv_cr ||
lv_cr ||
'-------SECBOUND'|| lv_cr ||
'Content-Type: text/plain;'|| lv_cr ||
' name="excel.csv"'|| lv_cr ||
'Content-Transfer_Encoding: 8bit'|| lv_cr ||
'Content-Disposition: attachment;'|| lv_cr ||
' filename="'||pv_file_name||'"'|| lv_cr ||
lv_cr ||lv_message_tab(lv_idx)
|| lv_cr || -- Content of attachment
lv_cr ||
'-------SECBOUND--' );
END LOOP;
END IF;
--This send the attachment for the rest of the data...for the last few iterations
IF lv_message IS NOT NULL
THEN
UTL_SMTP.HELO(lv_conn, lv_smtp_host);
UTL_SMTP.MAIL(lv_conn, gc_sender);
UTL_SMTP.RCPT(lv_conn, lv_to_email_ids);
UTL_SMTP.RCPT(lv_conn, lv_cc_email_ids);
UTL_SMTP.DATA(lv_conn,
'Date: ' || TO_CHAR(SYSDATE, gc_dd_month_yyyy_format) || lv_cr ||
'From: ' || gc_sender || lv_cr ||
'Subject: '|| lv_subject || lv_cr ||
'To: ' || lv_to_email_ids || lv_cr ||
'CC: ' || lv_cc_email_ids || lv_cr ||
'MIME-Version: 1.0'|| lv_cr || -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| lv_cr ||
' boundary="-----SECBOUND"'|| lv_cr ||
lv_cr ||
'-------SECBOUND'|| lv_cr ||
'Content-Type: text/plain;'|| lv_cr ||
' name="excel.csv"'|| lv_cr ||
'Content-Transfer_Encoding: 8bit'|| lv_cr ||
'Content-Disposition: attachment;'|| lv_cr ||
' filename="'||pv_file_name||'"'|| lv_cr ||
lv_cr ||lv_message
|| lv_cr || -- Content of attachment
lv_cr ||
'-------SECBOUND--' );
END IF;
UTL_SMTP.QUIT(lv_conn);
pv_rtn := TRUE;
ELSE
pv_rtn := FALSE;
END IF;
我通过将输入作为集合表来调用该过程,例如
程序
SP1_Send_letter_ATTACH_WAL(pv_job_id IN job.job_id%TYPE,
pv_status IN job_transaction_details.status_id%TYPE,
pv_subject IN VARCHAR2,
pv_message IN stringtable,
pv_file_name IN VARCHAR2,
pv_date_time IN DATE DEFAULT SYSDATE,
pv_rtn OUT BOOLEAN);
我只想将变量的数据存储到clob 数据类型pv_message
的变量中。lv_message
lv_message CLOB;
如何存储 lv_message := pv_message(即集合数据类型为 CLOB 类型)。我已经尝试过使用 'to_clob()' 函数进行类型转换,lv_message = to_clob(pv_message)
但它不起作用。