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;
你的需求是删除表中重复的数据,你参考下sql的解法:
http://space.itpub.net/519536/viewspace-620064
int 型?搞笑呢吧。。 oracle中用number型。把那个变量的int改成number(8),你这个存储过程是删除重复行的吧,根据某个关键字段来清除重复行,以前做过,很多种方式。可以一句SQL搞定,不过得看你的表数据量大小,数据量小的话,尝试下面这句SQL:
delete from compare_guoshui a,(select max(rowid) max_rowid,qyzch compare_guoshui color=violet[/color] group by qyzch ) b where a.qyzch =b.qyzch and a.rowid!= b.max_rowid
:oops: 怎么没有int类型,int类型是number的子类型。。。。
是么,一般用number。。。