Output columns from SELECT statement from stored procedure

34 Views Asked by At

Please forgive me, I am very green with PL/SQL stored procedures. I am writing a stored procedure that will take in an input parameter (OFF_Set) and run a SQL statement using OFFSET and FETCH functions.

This procedure is called from an Oracle Integration program (OIC) and will loop this procedure and increment the Off_set parameter each time, in order to avoid exceeding file size thresholds in the OIC program.

I have the below procedure written, however I am not sure how to output all the selected columns back to the calling OIC program. I saw some things about using the SYS_REFCURSOR to return all the rows output from the Select statement, but I'm not sure if how I have this written now will do that...I need to output each column individually.

create or replace PACKAGE BODY "DEPLETION_ERRORS_MONTHLY_PKG" 
AS

PROCEDURE RUN_SQL (OFF_Set IN NUMBER, p_errors out SYS_REFCURSOR)
IS BEGIN
OPEN p_errors for

  SELECT subinventory, source_code||'-'||trx_reference source_casenum_line,item_number,
item_description, error_msg, filename, creation_date, quantity_used, quantity_wasted, INV_ITEM_FLAG,
INV_CATEGORY_NAME 
from TGC_INT016_INV_DEPL_FBDI
where 1=1 
 and status='ERROR' 
 and creation_date >= add_months(trunc(sysdate,'mm'),-1) 
 and creation_date < trunc(sysdate, 'mm')
ORDER BY CREATION_DATE
OFFSET OFF_Set ROWS
FETCH NEXT 10000 ROWS ONLY;

END RUN_SQL;
END DEPLETION_ERRORS_MONTHLY_PKG;

EDIT:

enter image description here

0

There are 0 best solutions below