orcle 游标使用

来源:互联网 发布:筒灯和射灯品牌 知乎 编辑:程序博客网 时间:2024/05/08 10:06
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;

0 0
原创粉丝点击