首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-07-23 
信息更新时间数据订正.sql--产仔declare cursor r isselect p.animal_id as animal_id,max(p.produce_date

信息更新时间数据订正.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;

热点排行