各位大神,帮忙优化一下这段存储过程,最主要的是怎么去掉游标!
CREATE OR REPLACE PROCEDURE test_efrule(p_sysdate in varchar2,p_data_source_cd in int) is
V_SYSDATE DATE := TO_DATE(p_sysdate,'YYYY-MM-DD');
V_INS_TXT VARCHAR2(3000);
V_SEL_TXT VARCHAR2(3000);
FUNCTION F_FILO_SCOM(F_TAB VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
IF F_TAB IN('PD_PP_FIXED','PD_PP_FLOAT') THEN
RETURN ',OVERDUE_FLAG,OVERDUE_TERM,EARLY_REPAY,OVERDUE_TERM_UNIT';
END IF;
RETURN '';
END F_FILO_SCOM;
FUNCTION F_FILONIRS_SCOM(F_TAB VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
IF F_TAB IN('PD_PP_FIXED','PD_PP_FLOAT','PD_PP_NIRS') THEN
RETURN ',ORG_TERM_UNIT,MAT_DATE,ORG_TERM';
END IF;
RETURN '';
END F_FILONIRS_SCOM;
FUNCTION F_FILONDD_SCOM(F_TAB VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
IF F_TAB IN('PD_PP_FIXED','PD_PP_FLOAT','PD_PP_NDD') THEN
RETURN ',LAST_PAY_DATE,BUSINESS_LEVEL_CD,PAY_FREQ_UNIT,LAST_REPRICE_BAL,CHANNEL,PAY_BAL,'
|| 'PAY_FREQ,NEXT_PAY_DATE,INT_FLOAT_TYPE_CD,FLOAT_PROPORTION,BASE_FLT_VALUE,LAST_REPRICE_DATE,'
|| 'REPRICE_TYPE_CD,NEXT_REPRICE_DATE,PUBLISHER_CD,REPRICE_FREQ,REPRICE_FREQ_UNIT'
;
END IF;
RETURN '';
END F_FILONDD_SCOM;
begin
DELETE BP_INVALID_DATA T WHERE T.DATA_DATE = v_sysdate;
COMMIT;
FOR J IN (SELECT TRIM(DATA_SYSTEM_SOURCE1) t1,TRIM(DATA_SYSTEM_SOURCE2) t2,TRIM(DATA_SYSTEM_SOURCE3) t3,TRIM(DATA_SYSTEM_SOURCE4) t4,CHECK_SQL,ERROR_ID
FROM CP_VALID_CHECK_PARA
)