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

上一篇:.NET笔试题(关于迭代的:遍历XML中的FileName)


下一篇:oracle 导出导入常见问题