I can't seem to be able to run a package that contains a stored procedure that contains two parameters and outputs a table based on those parameters. The goal is to create a stored procedure that takes in the inputs, new_date and new_entity, and return the data from the table that matches these values.
CREATE OR REPLACE PACKAGE test1 IS
PROCEDURE stored_proc (new_date IN VARCHAR2, new_entity IN VARCHAR2, output OUT SYS_REFCURSOR);
END;
CREATE OR REPLACE PACKAGE BODY test1 IS
PROCEDURE stored_proc (new_date IN VARCHAR2, new_entity IN VARCHAR2, output OUT SYS_REFCURSOR) IS
BEGIN
OPEN output FOR select * FROM atlas_report_dates
WHERE report_date = TO_DATE(new_date,'mm/dd/yyyy') AND entity = new_entity;
END;
END;
BEGIN
test1.stored_proc('6/12/2023', 'MLFS');
END;
I'm getting errors ORA-06550, PLS-00306, ORA-06550
Your procedures are fine (you just need to make sure you terminate the PL/SQL blocks with the
/terminator on a new line after theEND;statement).The anonymous block you use to call the procedure is incorrect as the procedure takes three arguments and you have only provided two. You need to supply the cursor argument for the
OUTparameter.Then:
Works (but does not do anything as you have not told it what to do with the cursor).
Better, would be to use the column data types and pass dates as dates (and not strings):
Then you can call it using:
And the output for the sample table is:
fiddle