During migration from Oracle to PostgreSQL. I encounter a problem: Procedure with OUT parameters in a PostgreSQL package not working. Whenever run the procedure, it say procedure does not exist.
CREATE OR REPLACE PACKAGE pkg_productdetails
IS
Procedure p_getprod_details(in_locationid numeric, OUT cur_Product_typedetails refcursor, OUT cur_Productlist refcursor);
END pkg_productdetails;
CREATE OR REPLACE PACKAGE BODY pkg_productdetails
IS
Procedure p_getprod_details(in_locationid numeric, OUT cur_Product_typedetails refcursor, OUT cur_Productlist refcursor) IS
BEGIN
OPEN cur_Product_typedetails FOR
--select the cur_Product_typedetails ;
OPEN cur_Productlist FOR
--select the cur_Productlist;
END;
END pkg_productdetails;
when I run this procedure, it say pkg_productdetails.p_getprod_details(numeric) does not exist.
SELECT pkg_productdetails.p_getprod_details(10001);
One work around I got to handle this situation If we convert procedures to functions, its working.
CREATE OR REPLACE PACKAGE pkg_productdetails
IS
Function p_getprod_details(in_locationid numeric) RETURNS SETOF refcursor;
END pkg_productdetails;
CREATE OR REPLACE PACKAGE BODY pkg_productdetails
IS
FUNCTION p_getprod_details(in_locationid numeric) RETURNS SETOF refcursor IS
cur_Product_typedetails refcursor;
cur_Productlist refcursor;
BEGIN
OPEN cur_Product_typedetails FOR
--select the cur_Product_typedetails ;
return next cur_Product_typedetails;
OPEN cur_Productlist FOR
--select the cur_Productlist;
return next cur_Productlist;
END;
END pkg_productdetails;
when I run this package Function, it is working pkg_productdetails.p_getprod_details(numeric).
SELECT pkg_productdetails.p_getprod_details(10001);
returning <unnamed portal 1>
and <unnamed portal 2>