実行するたびに異なる結果を返す選択クエリがある for ループがあるというシナリオがあります。すべての結果を単一の変数または配列またはカーソルに格納する必要があります。提案してください!!.以下は、パッケージに記述された手順です。
パッケージ仕様:
TYPE t_product_id IS TABLE OF products.productnr%TYPE
INDEX BY PLS_INTEGER;
TYPE t_product_desc IS TABLE OF varchar(100)
INDEX BY PLS_INTEGER;
Type t_product_psnr IS TABLE OF prodsubs.PSNR%TYPE
INDEX BY PLS_INTEGER;
TYPE t_prod_contractperiod IS TABLE OF prodrul.CONTRPEROFPSNR%TYPE
INDEX BY PLS_INTEGER;
Type t_output IS TABLE OF prodrul.ALLOWEDCUSTTYPES%TYPE
INDEX BY PLS_INTEGER;
パッケージ本体:
PROCEDURE x_proc_Validprodcusttypeacctyp (
i_prodnr IN t_product_id,
i_invoiceprd IN prodrul.ALLOWEDINVPERIOD%TYPE,
i_psnr IN t_product_psnr,
i_contactprd IN t_prod_contractperiod,
i_result OUT t_output
)
IS
BEGIN
FOR i IN i_prodnr.FIRST .. i_prodnr.LAST
`LOOP
BEGIN
select PRODUCTNR,PRODUCTUSERKEY,ALLOWEDCUSTTYPES,ALLOWEDACCNTTYPES
into i_result (i)`
from prodrul rul join products prods on rul.PRODUCTNROFPSNR = prods.productnr
where prods.productnr = i_prodnr (i) and ALLOWEDINVPERIOD= i_invoiceprd and CONTRPEROFPSNR= i_contactprd (i)
and prods.productnr not in(select productnr from products where SMARTCARDYN = 1)
and rul.PRODUCTNROFPSNR not in (select PSPRODUCTNR from prodsubs join decoders on prodsubs.PSNR = decoders.DECSCPSNR where prodsubs.PSNR= i_psnr (i));
END;
END LOOP;
END x_proc_Validprodcusttypeacctyp;