это моё решение в зависимости от комментария Ильи Маскова, пакет
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;