0

我在 Oracle 中有一个 send_mail() 过程来处理所有的电子邮件。

我可以从 Zend 查询中调用该过程而没有错误$db->query("blah blah");,但是当我使用 a 时,$stmt = $db->prepare("blah blah");我得到了错误(尽管电子邮件仍然发送):

24374 ORA-24374: define not done before fetch or execute and fetch *begin send_mail(:mailto,:mailhost,:mailport,:mailfrom,:subject,:message); end;","file":"C:\\wamp\\www\\sam\\library\\Zend\\Db\\Statement\\Oracle.php

我所有的变量都定义了吗?所以不确定是什么导致了这个错误?

我的代码:

$db = Zend_Registry::get('db');

            $emailTo = trim($_POST['emailto']);
            $subject = trim($_POST['subject']);
            $message = trim($_POST['msg']);

        $eSettings = $db->query("Select MAIL_HOST, MAIL_PORT, MAIL_FROM from     PI_SETTINGS_TABLE")->FetchAll();

            $stmt = $db->prepare("begin send_mail(:mailto,:mailhost,:mailport,:mailfrom,:subject,:message); end;");
            $stmt->bindParam('mailto', $emailTo);
            $stmt->bindParam('mailhost', $eSettings[0]['MAIL_HOST']);
            $stmt->bindParam('mailport', $eSettings[0]['MAIL_PORT']);
            $stmt->bindParam('mailfrom', $eSettings[0]['MAIL_FROM']);
            $stmt->bindParam('subject', $subject);
            $stmt->bindParam('message', $message);
            $stmt->execute();
            $checkQuery = $stmt->FetchAll();

也许有人可以阐明为什么我可以将其作为查询而不是作为绑定语句传递?

我的 SEND_MAIL 程序:

create or replace
PROCEDURE "SEND_MAIL" (
msg_to varchar2,
mail_host varchar2,
mail_port varchar2,
msg_from varchar2,
msg_subject varchar2,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer;

BEGIN
c := utl_smtp.open_connection(mail_host, mail_port); -- SMTP on port 25
utl_smtp.helo(c, mail_host);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);

utl_smtp.data(c,'From: ' || msg_from || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || utl_tcp.crlf || msg_text);
utl_smtp.quit(c);

EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;

注意:当我使用绑定变量从 SQL Developer 运行查询时,我收到此错误并且电子邮件未发送:

ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "PI_USER_ADMIN.SEND_MAIL", line 15

但是它会用zend发送吗?

最亲切的问候

弥敦道

4

0 回答 0