N_DEL_ROWS :=0; --游标记录数 N_CNT :=1; -- 初始化该过程名称 V_PROC_NAME :='FSP_ETL_FUND_PAYMENT_BOE_DATA_IMP_PKG.SP_ETL_PAYMENT_BOE_HEADER'; --写存储过程开始记录 COM_SYS_LOG_PKG.SP_PROCESS_START(V_PROC_NAME); --获取最新的id值 SELECT GREATEST((SELECT GEN_VALUE FROM FSP_EAS.SYS_ID_GEN WHERE GEN_NAME ='seq_dms_boe_header'),(SELECT NVL(MAX(ID), 0) +1FROM FSP_EAS.DMS_BOE_HEADER)) INTO N_SEQ_ID FROM DUAL; --查询 FOR CUR_1 IN ( SELECT CREATION_DATE AS CREATION_DATE, LAST_UPDATED_DATE AS LAST_UPDATED_DATE, ENABLED_FLAG AS ENABLED_FLAG FROM FSP_EAS.DMS_MID_PAYMENT WHERE ENABLED_FLAG ='Y'AND ATTRIBUTE19 ISNULL) --开始循环 LOOP --判断是否需要修改,根据 资金单据号 SELECT COUNT(*) INTO V_COUNT FROM FSP_EAS.DMS_BOE_HEADER T WHERE T.BOE_NO = CUR_1.BOE_NO;
IF V_COUNT >0THEN --修改数据
BEGINUPDATE FSP_EAS.DMS_BOE_HEADER T SET VERSION = VERSION +1, LAST_UPDATED_DATE = CUR_1.LAST_UPDATED_DATE WHERE T.BOE_NO = CUR_1.BOE_NO; END;
N_UPD_ROWS := N_UPD_ROWS +1; ELSE BEGIN --新增数据 INSERT INTO FSP_EAS.DMS_BOE_HEADER(ID, VERSION, BOE_TYPE_CODE, CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE, ENABLED_FLAG) VALUES(N_SEQ_ID, 1, ( SELECT value FROM fsp_eas.sys_data_code WHERE code ='20' AND parent_id = ( SELECT id FROM fsp_eas.sys_data_code c WHERE c.code ='DMS_BOE_TYPE_CODE_SET')), -1, CUR_1.CREATION_DATE, -1, CUR_1.LAST_UPDATED_DATE, CUR_1.ENABLED_FLAG);
N_SEQ_ID := N_SEQ_ID +1;
N_INS_ROWS := N_INS_ROWS +1; END; END IF;
N_CNT := N_CNT +1;
IF MOD(N_CNT, 1000) =0THENCOMMIT; END IF; END LOOP; -- 修改序列值 UPDATE FSP_EAS.SYS_ID_GEN SET GEN_VALUE = N_SEQ_ID WHERE GEN_NAME ='seq_dms_boe_header'; --写存储过程结束记录 COM_SYS_LOG_PKG.SP_PROCESS_END(V_PROC_NAME, N_INS_ROWS, N_UPD_ROWS, N_DEL_ROWS);
COMMIT; -- 写异常处理信息,公用模块??成后,切入异常部分 EXCEPTION WHEN OTHERS THENNULL;
ROLLBACK;
V_ERROR_INFO := SUBSTR(SQLERRM, 1, 3600); --写执行失败信息 SYS_EXP_PKG.SP_PROCESS_ERROR(V_PROC_NAME, V_ERROR_INFO || N_CNT); -- 修改序列值 UPDATE FSP_EAS.SYS_ID_GEN SET GEN_VALUE = ( SELECT NVL(MAX(ID), 0) +1 FROM FSP_EAS.DMS_BOE_HEADER) WHERE GEN_NAME ='seq_dms_boe_header';
COMMIT; END; END FSP_ETL_FUND_PAYMENT_BOE_DATA_IMP_PKG;
CREATEOR REPLACE PACKAGE TEST_PACKAGE IS -- 定义过程一 PROCEDURE TEST_PROCEDURE_A(IN_PARAM IN VARCHAR2,OUT_PARAM OUT VARCHAR2); -- 定义过程二 PROCEDURE TEST_PROCEDURE_B(IN_PARAM IN VARCHAR2,OUT_PARAM OUT VARCHAR2); END TEST_PACKAGE;
与包体的编写(包含过程的实现)
1 2 3 4 5 6 7 8 9 10 11
CREATEOR REPLACE PACKAGE BODY TEST_PACKAGE IS PROCEDURE TEST_PROCEDURE_A(IN_PARAM IN VARCHAR2,OUT_PARAM OUT VARCHAR2) AS --定义变量 --XXX INTEGER --实际过程 BEGIN --XXXX END; COMMIT; END; END TEST_PACKAGE;