Oracle 中循环遍历某张表,并对符合条件的进行Update操作
BEGIN FOR L_RECORD IN (select RECORD_ID,CURR_PERIOD,PERIOD_START_DATE, (sysdate- PERIOD_START_DATE) diffTime,(P.PERIOD_END_DAY-P.PERIOD_BEGIN_DAY) periodDiffDay from CPS_PATIENT_PATH_RECORD t1 inner join cps_treat_period p on p.Period_Id=t1.Curr_Period where t1.path_state=1) LOOP IF (L_RECORD.DIFFTIME >=L_RECORD.periodDiffDay) THEN UPDATE CPS_PATIENT_PATH_RECORD SET PERIOD_START_DATE=to_date(to_char(sysdate,‘YYYY/MM/DD‘),‘YYYY/MM/DD‘),CURR_PERIOD =L_RECORD.CURR_PERIOD+1 WHERE RECORD_ID=L_RECORD.RECORD_ID; END IF; END LOOP; END;
格式:
FOR record IN (SELECT)
LOOP
UPDATE T WHERE
END LOOP
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。