APEX 3.2:页面处理如果声明

时间:2012-04-30 15:31:50

标签: oracle-apex

我正在尝试运行的页面流程,如果满足某些条件,它将发送电子邮件。但是,如果进程没有提取任何数据,我仍然希望页面正常打开。当以下Select语句运行时,我被困在'ORA-01403:找不到数据':

select issue_added_to_alm into issue_added from Table_2 WHERE issue_Requester = '1234' and Issue_Added_To_ALM = '1' and EMAIL_NOTIFICATION = '0';

如果我删除了初始select语句并用以下内容替换了IF语句:

IF :NEW.ISSUE_ADDED_TO_ALM = 1 THEN

我得到:ORA-01008:并非所有变量都绑定

我如何实现这一目标?

declare
 l_body varchar2(4000);
 l_to_address varchar2(2000);
 l_from varchar2(200) :='dq.issue.mgmt@jpmchase.com';
 l_summary varchar2(1000);
 l_description varchar2(4000);
 l_ALM_ID varchar2(100);
 l_subject varchar2(400);
 l_added_to_alm varchar2(200);
 issue_added varchar2(200);


begin

select 
issue_added_to_alm 
into issue_added 
from Table_2 
WHERE issue_Requester = '1234' 
and Issue_Added_To_ALM = '1' and EMAIL_NOTIFICATION = '0';

 if issue_added = 1 Then

        select EMP_EMAIL_NAME 
        into l_to_address
        from Table_1 where emp_id = '1234';

        select 
        ISSUE_Summary,ISSUE_DESCRIPTION,ALM_ISSUE_ID,email_notification 
        into l_summary,l_description,l_ALM_ID,l_added_to_alm
        FROM Table_2
        WHERE issue_Requester = '1234' and Issue_Added_To_ALM = '1' and EMAIL_NOTIFICATION = '0';

        l_subject := l_ALM_ID || 'Request has been created.';

        l_body :=  '<style type="text/css">
        p{font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size:12pt;
        margin-left:30px;
        }
        </style>';

                l_body := l_body ||  '<p>Your request has been created.</p>';
                l_body := l_body ||  '<p>Data Quality Center received the following request:</p>';
                l_body := l_body ||  '<p>Request ID: '|| l_ALM_ID ||'</p>';
                l_body := l_body ||  '<p>Request Title: '|| l_summary||'</p>';
                l_body := l_body ||  '<p>Request Description: '|| l_description||'</p>';



          HTMLDB_MAIL.SEND(
            P_TO        => l_to_address,
            P_FROM      => l_from,
            P_BODY      => l_body,
            P_BODY_HTML => l_body,
            P_SUBJ      => l_subject,
            P_CC        => l_from);

            wwv_flow_mail.push_queue(
           P_SMTP_HOSTNAME => 'mail.mailserver.net',
           P_SMTP_PORTNO => '12'
           );

           UPDATE Table_2 set EMAIL_NOTIFICATION = 1 where ALM_ISSUE_ID = :l_ALM_ID;

  end if;

  end;

非常感谢提前。

1 个答案:

答案 0 :(得分:2)

您只需要在最终end;之前添加一个异常处理程序:

   ...
exception
  when no_data_found then
    null;
end;