数据库查询错误:java.sql.SQLException:ORA-01422精确提取返回的请求行数超过ORA-06512:

时间:2014-04-15 17:42:06

标签: sql oracle

当我尝试在前端应用程序上生成报告时,我在前端遇到以下错误:

数据库查询错误:java.sql.SQLException:ORA-01422精确提取返回超过请求的行数ORA-06512:位于“.AUDIT_REPORT”,第4044行.MS Word无法生成。

以下是生产中的包AUDIT_REPORT中的功能代码,其中第4044行(SELECT语句)有错误。

FUNCTION AUD_REP (i_aud_id IN VARCHAR2)

RETURN CLOB
IS
   x_details CLOB;
   x_sec_text  varchar2(4000);
   x_sec_ref_num varchar2(1000);
   x_sec_name varchar2(1000);
   x_satisfactory varchar2(1000);
   x_minor varchar2(1000);
   x_major varchar2(1000);
   x_critical varchar2(1000);
   x_na varchar2(1000);
   x_sec_rat varchar2(1000);
   x_last varchar2(1000);


    CURSOR  CAT_Items
    IS 
        select instance_ID from SI_100357_T
        where (audit_id=i_aud_id and rem_action is null) OR (audit_id=i_aud_id and Overall_Comments is not null)
    ORDER by Title, METRIC_COMPLETED_DATE ;
    BEGIN

    x_details := '<body lang=EN-US style=''tab-interval:.5in''>
                  <div class=Section1>
                  <p style=''margin-bottom:0in;margin-bottom:''><o:p>&nbsp;</o:p></p>
                  <table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width=100%
                  style=''width:100%;mso-cellspacing:0in;''>
                   <thead>
                  <tr style=''mso-yfti-irow:0;mso-yfti-firstrow:yes''>
                   <td width=10% valign=top style=''width:10%; ''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Question</span></b>
                  </td>
                   <td width=5% valign=top style=''width:5%;''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Status</span></b>
                  </td>
                   <td width=5% valign=top style=''width:5%;''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Completion Date</span></b>
                  </td>   
                    <td width=5% valign=top style=''width:5%;''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Current Owner</span></b>
                  </td>
                    <td width=5% valign=top style=''width:5%;''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Question Rating</span></b>
                  </td> 
              <td width=5% valign=top style=''width:5%;''>
                   <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Original Due Date</span></b>
                  </td> 
                  <td width=65% valign=top style=''width:65%;''>
                  <b><span style=''font-size:8.0pt;font-family:Times New Roman;color:black;text-align:center''>Overall Comment History</span></b>
                  </td>  
                  </tr>
                  </thead>';


FOR items in CAT_Items

LOOP   
**select BB.TITLE**,
case A.STATUS
when '2' then 'CLOSED'
else 'OPEN' end as STATUS,
Completed.COMPLETE,
F.First_name||' ' ||F.Last_name as Current_Owner,
REM_CUSTOM_COL1,
BB.Issue_Due_Date,
CC.First_name||' '||CC.Last_name||'- '||BB.Event_Creation_Date||'- '||BB.Overall_comments

into x_sec_ref_num,x_sec_name,x_satisfactory,x_minor,x_major,x_critical,x_na

FROM SI_100357_T BB 
left outer join SI_USERS_T CC on BB.Event_user_name=CC.user_name 
left outer join SI_Event_Assignments E on BB.process_instance_ID=E.process_instance_ID
left outer join SI_users_T F on E.user_ID=F.user_ID
left outer join MS_AUD_AUDIT_REMEDIATIONS A on BB.Simplified_CAPA_ID=A.Remediation_ID

left outer join (
select BBB.Metric_Completed_Date as COMPLETE, BBB.Simplified_CAPA_ID as IDENT
from MS_AUD_AUDIT_REMEDIATIONS AAA
left outer join SI_100357_T BBB on AAA.Remediation_ID=BBB.Simplified_CAPA_ID
Where AAA.Audit_ID=i_aud_id and BBB.rem_action='290'
group by 
BBB.Metric_Completed_Date, BBB.Simplified_CAPA_ID) COMPLETED on COMPLETED.IDENT=A.REMEDIATION_ID

Where  (BB.instance_ID=items.instance_ID)
ORDER by REM_CUSTOM_COL1,BB.Title, BB.METRIC_COMPLETED_DATE ;

         x_details :=  x_details ||'
                              <tr style=''mso-yfti-irow:1;mso-yfti-lastrow:yes''>
                            <td width=10% valign=top style=''width:10%;''>
                            <span style=''font-size:10.0pt;color:black;text-align:center''><span
                            class=SpellE>'||x_sec_ref_num||'</span>
                            </td>
                            <td width=5% valign=top style=''width:5%;''>
                            <span style=''font-size:9.0pt;color:black''><span
                            class=SpellE>'||x_sec_name||'</span><o:p>
                            </td>
                            <td width=5% valign=top style=''width:5%;''>
                            <span style=''font-size:9.0pt;color:black''><span
                            class=SpellE>'||x_satisfactory||'</span>
                            </td> 
                            <td width=5% valign=top style=''width:5%;''>
                            <span style=''font-size:9.0pt;color:black''><span
                            class=SpellE>'||x_minor||'</span>
                            </td>  
                            <td width=5% valign=top style=''width:5%;''>
                            <span style=''font-size:9.0pt;color:black''><span
                            class=SpellE>'||x_major||'</span>
                            </td>    
                            <td width=5% valign=top style=''width:5%;''>
                            <span style=''font-size:9.0pt;color:black''><span
                            class=SpellE>'||x_critical||'</span>
                            </td>         
                            <td width=65% valign=top style=''width:65%;''>
                            <span style=''font-size:8.0pt;color:black''><span
                            class=SpellE>'||x_na||'</span>
                            </td> 
                            </tr>';

       END LOOP;

    x_details :=  x_details ||'</table>
                                <p class=MsoNormal><o:p>&nbsp;</o:p></p>
                                </div>
                                </body>';

    RETURN x_details;

END AUD_REP;

我最初认为SELECT INTO可能是错误的,因为它每次都必须返回多行。但是这个代码似乎适用于其他审计ID。在尝试生成报告时,有7个审核ID显示此错误。我不知道如何找出问题所在以及修复的位置。如果这是一个数据级问题,我该怎么办呢?

非常感谢任何帮助。感谢。

0 个答案:

没有答案