当前位置: 代码迷 >> SQL >> 信息更新时间数据勘误.sql
  详细解决方案

信息更新时间数据勘误.sql

热度:93   发布时间:2016-05-05 15:02:34.0
信息更新时间数据订正.sql
--产仔declare cursor r isselect p.animal_id as animal_id,max(p.produce_date)as produce_date from tbl_produce p join tbl_animal_info a on p.animal_id= a.id group by p.animal_id;thedata r%rowtype;begin  open r;        loop             fetch r into thedata;             exit when r%notfound;                           update tbl_animal_info o                   set o.update_time = thedata.produce_date                   where (o.update_time < thedata.produce_date or o.update_time is null) and  o.id=thedata.animal_id ;                   commit;                   end loop;end;--如果更新时间为空update tbl_animal_info a set a.update_time =a.create_timewhere a.update_time is null or a.update_time<a.create_time;commit;--更新时间大于目前系统时间update tbl_animal_info set update_time =sysdate where update_time>sysdate;commit;
  相关解决方案