2016-07-29 37 views
0

從Oracle遷移到PostgreSQL期間。我遇到一個問題: PostgreSQL包中的OUT參數無效的過程。每當運行程序時,它說程序不存在PostgreSQL包中OUT參數不起作用的過程

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; 

當我運行這個程序,它說pkg_productdetails.p_getprod_details(數字)不存在

SELECT pkg_productdetails.p_getprod_details(10001); 
+0

@ a_horse_with_no_name是我使用EnterpriseDB公司 – Paarth

+0

你叫它有3個參數只有一個,其中兩個是OUT的程序?您需要兩個遊標變量才能發送到此過程。 – Mottor

+0

@Mottor當我們從所有3個參數(1 IN和2 OUT)的代碼調用這個pacakge.procedure時。它給出同樣的錯誤。 – Paarth

回答

0

一個解決我如果我們把程序的功能,它的工作來處理這種情況 。

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; 

當我運行此包功能,它是工作pkg_productdetails.p_getprod_details(數字)。

SELECT pkg_productdetails.p_getprod_details(10001); 

返回<unnamed portal 1><unnamed portal 2>