逻辑变量pdxtzd 初值为true,判断记录是否相等
datastore a
a = create datastore
a.dataobject="dbf"
a.settransobject(sqlca)
a.retrieve()
datastore b
b = create datastore
b.dataobject="dbf"
b.settransobject(sqlca)
b.retrieve()
for i=1 to a.rowcount()
for j=1 to b.rowcount()
if a.getitemX(i,"字段1")<>b.getitemX(j,"字段1") then pdxtzd = false
if a.getitemX(i,"字段2")<>b.getitemX(j,"字段2") then pdxtzd = false
if a.getitemX(i,"字段3")<>b.getitemX(j,"字段3") then pdxtzd = false
if a.getitemX(i,"字段4")<>b.getitemX(j,"字段4") then pdxtzd = false
.......
if a.getitemX(i,"字段n")<>b.getitemX(j,"字段n") then pdxtzd = false
end if
next
if pdxtzd = true then a.deleterow(i)
next
a.update()
declare
a1 number;
b1 number;
x rowid;
cursor a is select rowid,a ,b from test;
begin
open a;
loop
fetch a into x, a1,b1;
delete from test where a=a1 and b=b1;
insert into test values (a1,b1);
commit;
exit when a%notfound;
end loop;
close a;
end ;
declare
a1 number;
b1 number;
x rowid;
cursor a is select rowid,a ,b from test;
begin
open a;
loop
fetch a into x, a1,b1;
delete from test where a=a1 and b=b1 and not(rowid=x);
exit when a%notfound;
end loop;
close a;
end;
select distinct column1,column2,...,cast(memo列 as varchar(8000)) as memo列
into #tmptable from yourtable
truncate table yourtable
insert into yourtable from #tmptable
oracle:
delete from mytable t1 where rowid<>(select max(rowid) from mytable t2 where t1.dupfield=t2.dupfield)
sqlserver:
create table #mytb (f1 int,dupfield, .....)
create index idx_mytb on #mytb(dupfield) WITH IGNORE_DUP_KEY
insert into #mytb select * from mytable
truncate table mytable
insert into mytable from #mytb