PL / SQL函数返回视图RowType内部异常

时间:2018-12-05 11:45:21

标签: oracle plsql stored-functions plsql-package

我具有以下要编译的功能。 VIEW的DOC_ISSUE_REFERENCE站

 CREATE OR REPLACE
    PACKAGE BODY INHOUSE_CUST_API
    AS
    FUNCTION Get_Budget_Doc(
        company             IN VARCHAR2,
        budget_process_id   IN VARCHAR2,
        budget_ptemplate_id IN VARCHAR2)
      RETURN DOC_ISSUE_REFERENCE%ROWTYPE
    IS
      enhDocItem ENHANCED_DOC_REFERENCE_OBJECT%ROWTYPE;
      docKeyValue VARCHAR2(150);
      docIssueRef DOC_ISSUE_REFERENCE%ROWTYPE;
    BEGIN
      docKeyValue := company||'^'||budget_process_id||'^'||budget_ptemplate_id||'^';
     -- dbms_output.put_line(docKeyValue);
      SELECT *
      INTO enhDocItem
      FROM ENHANCED_DOC_REFERENCE_OBJECT
      WHERE KEY_VALUE= docKeyValue;
      SELECT *
      INTO docIssueRef
      FROM DOC_ISSUE_REFERENCE
      WHERE DOC_NO = enhDocItem.DOC_NO;
      RETURN docIssueRef;
    END Get_Budget_Doc;
    END INHOUSE_CUST_API;

在这里,当我调用函数时会收到

ORA-06553: PLS-801: internal error [55018]
06553. 00000 -  "PLS-%s: %s"
*Cause:    
*Action:

不显示任何内容或帮助。我确定两个选择都只返回1行。感谢您的帮助

1 个答案:

答案 0 :(得分:0)

这是我的解决方案,具体取决于Ilia Maskov的评论 包裹是

create or replace 
PACKAGE INHOUSE_CUST_API
AS
TYPE doc_rec
IS
  RECORD
  (
    doc_Title    doc_issue_reference.title%Type,
    doc_Number   DOC_ISSUE_REFERENCE.DOC_NO%TYPE,
    doc_Type    DOC_ISSUE_REFERENCE.FILE_TYPE%TYPE,
    doc_FileName DOC_ISSUE_REFERENCE.FILE_NAME%TYPE,
    doc_Path     DOC_ISSUE_REFERENCE.PATH%TYPE);
TYPE doc_rec_tab IS TABLE OF doc_rec;
  FUNCTION Get_Budget_Doc(
      company             IN VARCHAR2,
      budget_process_id   IN VARCHAR2,
      budget_ptemplate_id IN VARCHAR2)
    RETURN doc_rec_tab PIPELINED;
END INHOUSE_CUST_API;

身体是

create or replace 
PACKAGE BODY INHOUSE_CUST_API
AS
FUNCTION Get_Budget_Doc(
    company             IN VARCHAR2,
    budget_process_id   IN VARCHAR2,
    budget_ptemplate_id IN VARCHAR2)
  RETURN doc_rec_tab PIPELINED
IS
  enhDocItem ENHANCED_DOC_REFERENCE_OBJECT%ROWTYPE;
  -- docIssueRef DOC_ISSUE_REFERENCE%ROWTYPE;
  docKeyValue ENHANCED_DOC_REFERENCE_OBJECT.KEY_VALUE%TYPE;
  docIssueRef_rec doc_rec;
  docTable doc_rec_tab;
BEGIN
  docKeyValue := company||'^'||budget_process_id||'^'||budget_ptemplate_id||'^';
    <<outer_loop>>
  FOR doc_no_rec IN (SELECT DOC_NO FROM ENHANCED_DOC_REFERENCE_OBJECT WHERE KEY_VALUE= docKeyValue) LOOP
  --dbms_output.put_line(doc_no_rec.rownum);
  <<inner_loop>>
    FOR rec_ IN(SELECT Title, DOC_NO,FILE_TYPE,FILE_NAME,PATH FROM DOC_ISSUE_REFERENCE WHERE DOC_NO = doc_no_rec.DOC_NO) LOOP
  PIPE row(rec_);
    END LOOP inner_loop;
  END LOOP outer_loop;
  RETURN;
END Get_Budget_Doc;
END INHOUSE_CUST_API;