create or replace procedure update_am_pm is -- 根据time_from列更新ampm为上午或下午,12点为分界线 cursor ampm_cursor is select t.time_from, t.ampm, t.id from usert; ampm_c ampm_cursor%rowtype; hour_ampm number; begin for ampm_c in ampm_cursor loop hour_ampm := to_number(to_char(ampm_c.time_from, 'hh24')); if hour_ampm <= 12 then update user t set t.ampm='上午' where t.id= ampm_c.id; else update user t set t.ampm='下午' where t.id= ampm_c.id; end if; end loop; end update_am_pm;