Oracle 中循环遍历某张表,并对符合条件的进行Update操作

前端之家收集整理的这篇文章主要介绍了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'),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

猜你在找的Oracle相关文章