Is there a way to execute a package function in Oracle PL/SQL?
Here is a sample package with a function that returns a Ref Cursor:
create or replace PACKAGE "PKG_PACKAGE1"
AS
TYPE CURS_OUT IS REF CURSOR;
FUNCTION fnc_PACKAGE1(PARAM1 VARCHAR2, PARAM2 INT) RETURN CURS_OUT;
END "PKG_PACKAGE1";
create or replace PACKAGE BODY "PKG_PACKAGE1"
AS
FUNCTION fnc_PACKAGE1(PARAM1 VARCHAR2, PARAM2 INT) RETURN CURS_OUT
AS
RUNCURS CURS_OUT;
BEGIN
OPEN RUNCURS FOR
SELECT 'Data Returned' FROM DUAL;
RETURN RUNCURS;
END;
END "PKG_PACKAGE1";
Here is how I want to execute it in PL/SQL using SQL Developer Tools:
BEGIN
:returnRes := PKG_PACKAGE1.FNC_PACKAGE1(:PARAM1,:PARAM2);
END;
OR
Declare
returnRes Varchar2(200);
BEGIN
returnRes := PKG_PACKAGE1.FNC_PACKAGE1(:PARAM1,:PARAM2);
END;
When I run either I get error: PLS-00382: expression is of wrong type. When I run the package through the wizard it to returns the value.
Is there a specific way to execute packages this way or is it not possible?
Thanks.