用table的话:
table1.first;
while not table1.eof do
begin
if table2.locate('keyfieldname', table1.fieldbyname('keyfieldname').value) then
table2.edit
else
table2.append;
table1.getcurrentrecord(table2.activebuffer);
table2.post;
table1.next;
end;
sql="select * from table2 where id=" & id
set rs=conn.execute(sql)
ok=false
if not rs.eof then
ok=true
end if
rs.close
if ok then
sql="insert into table2 (id,f1,f2,f3...) values (" & ......... & ")"
else
sql="update table2 set f1=" & ....... & " where id=" & id
end if
set rs=conn.execute(sql)