update 语句执行慢优化后老报错请高手指教
执行慢的语句
Update DIAGNOSIS@hiscs a
set (DIAGNOSIS_TYPE,---- 诊断类别
DIAGNOSIS_NO,---- 诊断序号
DIAGNOSIS_DESC,---- 诊断
DIAGNOSIS_DATE,---- 诊断日期
TREAT_DAYS,---- 治疗天数
TREAT_RESULT,---- 治疗结果
OPER_TREAT_INDICATOR,---- 手术治疗标志
DIAGNOSIS_CODE,---- 诊断代码
INSERT_INDICATOR)=(Select
b.DIAG_TYPE ,---- 诊断类别
b.DIAGNOSIS_NO,---- 诊断序号
SUBSTR(b.DIAG_DESC,1,40),---- 诊断
b.DIAG_DATE,---- 诊断日期
b.DOCTOR_DAYS,---- 治疗天数
b.DOCTOR_RESULT,---- 治疗结果
b.OPER_DOCTOR,---- 手术治疗标志
b.DIAG_NO,---- 诊断代码
b.INSERT_INDICATOR
From V_EMR_DIAG b
Where b.NAD IS NOT NULL AND
a.PATIENT_ID=b.PATIENT_ID And
a.VISIT_ID=b.NAD And
a.DIAGNOSIS_TYPE=b.DIAG_TYPE And
a.DIAGNOSIS_NO=b.DIAGNOSIS_NO )
Where exists(Select PATIENT_ID---- 病人标识
From V_EMR_DIAG
Where V_EMR_DIAG.NAD IS NOT NULL AND
a.PATIENT_ID=V_EMR_DIAG.PATIENT_ID And
a.VISIT_ID=V_EMR_DIAG.NAD And
a.DIAGNOSIS_TYPE=V_EMR_DIAG.DIAG_TYPE And
a.DIAGNOSIS_NO=V_EMR_DIAG.DIAGNOSIS_NO
);
改后的语句
Update
(Select a.DIAGNOSIS_TYPE,---- 诊断类别
a.DIAGNOSIS_NO,---- 诊断序号
a.DIAGNOSIS_DESC,---- 诊断
a.DIAGNOSIS_DATE,---- 诊断日期
a.TREAT_DAYS,---- 治疗天数
a.TREAT_RESULT,---- 治疗结果
a.OPER_TREAT_INDICATOR,---- 手术治疗标志
a.DIAGNOSIS_CODE,---- 诊断代码
a.INSERT_INDICATOR,
b.DIAG_TYPE ,---- 诊断类别
b.DIAGNOSIS_NO as zdxh,---- 诊断序号
b.DIAG_DESC,---- 诊断
b.DIAG_DATE,---- 诊断日期
b.DOCTOR_DAYS,---- 治疗天数
b.DOCTOR_RESULT,---- 治疗结果
b.OPER_DOCTOR,---- 手术治疗标志
b.DIAG_NO,---- 诊断代码
b.INSERT_INDICATOR as aa
From V_EMR_DIAG b left join DIAGNOSIS@hiscs a on
a.PATIENT_ID=b.PATIENT_ID And
a.VISIT_ID=b.NAD And
a.DIAGNOSIS_TYPE=b.DIAG_TYPE And
a.DIAGNOSIS_NO=b.DIAGNOSIS_NO
Where b.NAD IS NOT NULL AND
b.DIAG_TYPE is not null
)
set a.DIAGNOSIS_TYPEO=b.DIAG_TYPE,
a.DIAGNOSIS_NO=b.zdxh,
a.DIAGNOSIS_DESC=b.DIAG_DESC,
a.DIAGNOSIS_DATE=b.DIAG_DATE,
aTREAT_DAYS=b.DOCTOR_DAYS,
a.TREAT_RESULT