获取异常 PLS-00103 并且似乎是正确的

Getting exception PLS-00103 and seems to be correct

这里的代码好像没问题。我收到此异常 :( 请纠正我。 获取异常 PLS-00103 并且似乎是正确的

这里的代码好像没问题。我收到此异常 :( 请纠正我。 获取异常 PLS-00103 并且似乎是正确的

DECLARE

l_body varchar2(5000);
l_body_html varchar2(5000);
l_workspace_id number;
DiscontinuationEmail varchar2(5000);
DiscontinuationSubject varchar2(5000);
Discontinuation varchar2(5000);
DiscontinuationCC varchar2(5000);
DiscontinuationReminder number;

cursor cDiscontinuation is select NETSEC_TEAM.ENGINEER_EMAIL as ENGINEER_EMAIL,
    NETSEC_TEAM.NETSEC_MGR as NETSEC_MGR 
 from NETSEC_TEAM NETSEC_TEAM 
Where NETSEC_TEAM.NETSEC_MGR <> 'ALL'
MINUS
select NETSEC_PROCOMPLIANCE_1.EMPLOYEE_EMAIL as EMPLOYEE_EMAIL,
NETSEC_PROCOMPLIANCE_1.MANAGER_EMAIL as MANAGER_EMAIL
from NETSEC_PROCOMPLIANCE_1 NETSEC_PROCOMPLIANCE_1
Where NETSEC_PROCOMPLIANCE_1.DOCUMENT_NAME ='Discontinuation of Daily BI Agent Reports';
    -- ****        
    DOD cDiscontinuation%rowtype;

BEGIN
  l_workspace_id := apex_util.find_security_group_id (p_workspace => 'CIT-CSCOE-PROD');
apex_util.set_security_group_id (p_security_group_id => l_workspace_id);        

    /* *********** Discontinuation ********************** */     

OPEN cDiscontinuation
Discontinuation :='';
DiscontinuationCC :='';
DiscontinuationReminder := 1;

SELECT REMINDER INTO DiscontinuationReminder
FROM NETSEC_COMPLIANCE_REMINDER WHERE COMPLIANT ='Discontinuation';

Loop
FETCH cDiscontinuation INTO DOD;
 EXIT WHEN cDiscontinuation%NOTFOUND;
         Discontinuation := Discontinuation || ','|| DOD.ENGINEER_EMAIL;
         DiscontinuationCC := DiscontinuationCC || ','|| DOD.NETSEC_MGR;
 END LOOP;   
UPDATE NETSEC_COMPLIANCE_REMINDER SET REMINDER = DiscontinuationReminder+1  
WHERE COMPLIANT ='Discontinuation';
DiscontinuationReminder := DiscontinuationReminder + 1;

CLOSE cDiscontinuation;

DiscontinuationEmail:='TO: '|| Discontinuation ||' <br><br>  CC: ' || DiscontinuationCC ||'

<p>If you are a "To:" recipient of this email, it means that you are not in compliance with the following Network Services team announcement:<br />
If you are a "Cc:" recipient of this email, it means that one or more of your employees are not in compliance with the following Network Services team announcement:</p>

<p><a href="https://apex.oraclecorp.com/pls/apex/f?p=1648:522">Discontinuation of Daily BI Agent Reports</a></p>

<p>Please click on the link above and acknowledge and confirm your understanding of the process.</p>

<p>Thank you.</p>';

Discontinuation:= '***** NON-COMPLIANT ***** Discontinuation of Daily BI Agent Reports- RELEASE DATE 25 MAY 2016';     

     apex_mail.send(
     p_to        => 'bernardo.troncoso@oracle.com',
     p_from      => 'bernardo.troncoso@oracle.com',
     p_cc        => '',
     p_body      => DiscontinuationSubject,
     p_body_html => DiscontinuationEmail,
     p_subj      => 'REMINDER #'|| DiscontinuationReminder || ' ' || DiscontinuationSubject,
      p_bcc => '',
      p_replyto => NULL
     );    
END;

您在

之后少了一个分号
OPEN cDiscontinuation

只是对样式的评论:您将 OPEN 与 FETCH 分开有什么原因吗?您还可以使用 CURSOR FOR LOOP - 只是稍微清理一下代码。所以而不是:

OPEN cDiscontinuation
LOOP
FETCH cDiscontinuation INTO DOD;
 EXIT WHEN cDiscontinuation%NOTFOUND;
         Discontinuation := Discontinuation || ','|| DOD.ENGINEER_EMAIL;
         DiscontinuationCC := DiscontinuationCC || ','|| DOD.NETSEC_MGR;
 END LOOP;

你可以编码

FOR R_discontinuation IN cDiscontinuation LOOP
  Discontinuation := Discontinuation || ','|| R_discontinuation.ENGINEER_EMAIL;
  DiscontinuationCC := DiscontinuationCC || ','|| R_discontinuation.NETSEC_MGR;
END LOOP ;

在这种情况下,R_discontinuation 完全等同于第一个示例中的 DOD(即 cDiscontinuation%ROWTYPE),但它是隐式声明的。

使用 CURSOR FOR LOOP 并不比您的方法更正确,只是更清洁