我可以在循环中编写引用光标吗?可能吗?否则给出建议?
FOR bd_id_rec IN (SELECT BD_ID FROM DEAL D WHERE D.BD_NR=BD_NR_REC.BD_NR AND BD_VERSION_NR IN (SELECT MAX(BD_VERSION_NR) FROM DEAL D WHERE D.BD_NR=BD_NR_REC.BD_NR AND QUOTE_DIST_CD='A'))
LOOp
open v_refcursor for(SELECT D.BD_NR,D.BD_ID, D.BD_VERSION_NR, L.PROD_GNRC_NR_TX, L.PROD_OPT_CD, LD.AUTH_BD_NET_PRC_AM, D.W_L_STAT_CD, L.LINE_NR FROM DEAL D, LINE_ITEM L, LINE_DISC_SCALE LD, EU_CUST E
WHERE
D.BD_ID=bd_id_rec.bd_id
AND D.CONTROL_CNTRY_CD=l_control_cntry_cd
AND D.BUS_MODEL_CD=l_bus_model_cd
AND D.MC_CHARGE=l_mc_charge
AND D.QUOTE_DIST_CD=l_quote_dist_cd
AND D.QUOTE_DIST_DT_GMT>SYSDATE-60
AND LD.SCALE_ID IN (SELECT MAX(SCALE_ID) FROM LINE_DISC_SCALE WHERE bd_id=d.bd_id)
AND LD.BD_ID=D.BD_ID
AND LD.LINE_NR=L.LINE_NR
AND E.DFT_ENDCUST_OTRPRTYSITE_INSTID=l_dft_otrprtysite
AND E.DFT_ENDCUST_OTRPRTYSITE_ID=l_dft_endcust_otrprt_id
AND L.PROD_GNRC_NR_TX=prod_rec.PROD_GNRC_NR_TX
AND L.LINE_TYPE_CD='PN'
AND L.BD_ID=D.BD_ID
AND D.EU_CUST_NR=l_eu_cust_nr)
LOOP
end loop;
有可能吗?也提供示例代码。给我建议如何在循环中使用Ref游标?
答案 0 :(得分:0)
当然,您可以使用嵌套循环来迭代游标。 E.g。
-- iterate through first cursor
FOR rec_cursor1 IN (SELECT column1, column2 FROM my_table1) LOOP
-- iterate through second cursor
FOR rec_cursor2 IN (SELECT * FROM my_table2 t2 WHERE t2.column1 = rec_cursor1.column2 ) LOOP
-- some actions or another nested loop
END LOOP;
END LOOP;