我有一个存储过程,突然陷入合并,但是已经运行了好几年。有什么建议吗?该SP在Oracle SQL Developer中,并在Visual Studios SSIS程序包中执行
以下查询:
MERGE INTO CORE_APPT C
USING (
SELECT DISTINCT
TST_TKR_ID,
TST_TKR_ID_SRC,
APPT_ID_SRC,
APPT_CRETN_DTE,
APNTMT_DT,
ETS_APNTMT_ID,
ETS_TST_CNTR,
TST_STS_TYP_DESC,
APPT_STS_TYP,
TST_DLVR_MTHD_TYP_CDE,
DLVR_GRP_TYP,
TST_LNCH_TM,
TRNSCTN_ID,
TST_PKG_ID,
RND_TRIP_TST_FLG,
UPDT_DTE_TM,
PROD_ID,
ACTN_DTE_TM,
TST_DURN,
BRKRG_APPT_UPDT_DTM,
TST_APPT_TYP_CDE,
CNCL_MKUP_RSN_TYP,
DLNQNT_HLD_FLG,
TST_TKR_TST_UPDT_DTE_TM,
SCR_HLD_LVL_TYP_CDE,
SCR_CNCL_FLG,
ETS_CANDTE_SCR_HLD_FLG,
TST_CNTR_HLD_FLG,
TST_ADM_HLD_FLG,
ETS_SCR_CNCL_FLG,
TST_ADM_HLD_RSN_CDE,
TST_CNTR_HLD_RSN_CDE,
ETS_CANDTE_SCR_HLD_RSN_CDE,
ETS_SCR_CNCL_RSN_CDE,
DLNQNT_HLD_RSN_CDE,
TST_TKR_SCR_STS_TYP_CDE,
TST_TKR_SCR_STS_RSN_TYP_CDE,
PYMT_NO,
DATA_SRCE AS DATA_SRCE,
CURRENT_FLAG,
PRGRM_TYP,
sysdate as RCD_CRTD_DTE,
user as RCD_CRTD_USER,
REG_SYS_ID AS REG_SYS_ID,
TST_NAM AS TST_NAM,
CNTRY_SETL_RSP AS CNTRY_SETL_RSP
FROM STG_CMMN_APPT A
WHERE A.CURRENT_FLAG = 'Y'
) S
ON (C.APPT_ID_SRC = S.APPT_ID_SRC
AND C.REG_SYS_ID = S.REG_SYS_ID
AND C.DATA_SRCE = S.DATA_SRCE) -- added in EREG4.0 changes
WHEN MATCHED THEN UPDATE
SET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