第一个存储过程
第一个存储过程:
CREATE OR REPLACE PROCEDURE SYNCHRONOUS_TB_CON_HIS1(BEGINDATE IN VARCHAR2,ENDDATE IN VARCHAR2) IS /****************************************** -- Author : GL -- Created : 2018/01/23 -- Purpose : 按日期导入商户信息tb_con_his反洗钱 *********************************************/ --定义变量 MERCHANT_NOO VARCHAR2(256); --商户号 ACCNOO VARCHAR2(256); --结算账号 NUMM NUMBER; -- 购卡消费间隔天数 --定义游标 CURSOR cur_ids IS select a.mrchno mrchno, t.accno accno from merchant_x@DBLINK_TO_CORTEX a ,mrch_acc_x@DBLINK_TO_CORTEX t where t.mrchno = a.mrchno and a.add_date between BEGINDATE and ENDDATE; BEGIN --循环开始 LOOP IF NOT cur_ids%ISOPEN THEN OPEN cur_ids; END IF; FETCH cur_ids INTO MERCHANT_NOO, ACCNOO; --退出循环的条件 EXIT WHEN cur_ids%NOTFOUND OR cur_ids%NOTFOUND IS NULL; select count(*) into NUMM from tb_con_his T1 where T1.Join_Code = MERCHANT_NOO and T1.Self_Acc_No = ACCNOO; if NUMM=0 then insert into tb_con_his (JOIN_CODE,ACC_NAME1,OPEN_TIME,ADDRESS,ORG_NO,LICENSE,LICENSE_DEADLINE,REP_LEGAL,ID_NO2, ID_DEADLINE2, HANDLER_NAME,ID_NO3,ID_DEADLINE3,SELF_ACC_NO,BANK_ACC_NAME,PROF_TYPE,ACC_NAME, ACC_TYPE,BORD_FLAG,NATION,CLOSE_TIME,OPERATE,SET_FILE,MAN_NAME,ID_TYPE1,ID_NO1,ID_DEADLINE1, ID_TYPE2,ID_TYPE3,CODE,ACC_TYPE1) select a.mrchno, substr(a.mrcht_name, 0, 26), substr(a.add_date, 0, 8), a.address, substr(a.org_id, 0, 10), a.bus_lic_no, to_char(a.bus_lic_validity, 'yyyymmdd'), a.legal_rep, a.lr_id_no, to_char(a.lr_id_validity, 'yyyymmdd'), a.agent, a.id_no, to_char(a.id_validity, 'yyyymmdd'), t.accno, substr(t.acc_nick_name, 0, 26), '11', '@N', '12', '11', 'CHN', '@N', '@N', '11', '@N', '@N', '@N', '@N', '11', '11', '@N', '12' from merchant_x@DBLINK_TO_CORTEX a ,mrch_acc_x@DBLINK_TO_CORTEX t where t.mrchno = a.mrchno and a.mrchno = MERCHANT_NOO and t.accno = ACCNOO and a.add_date between BEGINDATE and ENDDATE; end if; END LOOP; COMMIT; END SYNCHRONOUS_TB_CON_HIS1;