yybing110 2011-10-20 16:55 采纳率: 0%
浏览 249
已采纳

谁能帮忙把这个oracle上的存储过程优化下

create or replace procedure delMoreByQyzch is
lostCount int:=0;
begin
for v in (select * from compare_guoshui ) loop
select count(*)into lostCount from compare_guoshui where qyzch=v.qyzch;
if lostCount !=1 then
delete from compare_guoshui c where c.qyzch=v.qyzch and c.id != v.id;
commit;
end if;
end loop;

end delMoreByQyzch;

  • 写回答

4条回答 默认 最新

  • iteye_8576 2011-10-20 17:13
    关注

    你的需求是删除表中重复的数据,你参考下sql的解法:
    http://space.itpub.net/519536/viewspace-620064

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?