| View previous topic :: View next topic |
| Author |
Message |
Bpk. Adi Wira Kusuma Guest
|
Posted: Thu Mar 17, 2005 6:22 pm Post subject: How to delete the data which double by quickly? |
|
|
I Use foxpro. My datas have been double. How to delete the data which double
by quickly? When I index with unique, data just still be double.
How to avoid the data double quickly and precisely?
|
|
| Back to top |
|
 |
Dell Stinnett Guest
|
Posted: Thu Mar 17, 2005 9:24 pm Post subject: Re: How to delete the data which double by quickly? |
|
|
Index on your key field(s), non-unique.
sKey := ''; //I'm using a string here - use whatever type your key field
is.
while not tMyTable.eof do
begin
if tMyTable.FieldByName('KEY_FIELD').AsString <> sKey then
begin
sKey := tMyTable.FieldByName('KEY_FIELD').AsString;
tMyTable.Next;
end
else
tMyTable.Delete;
end;
Note that you do NOT do tMyTable.Next after the tMyTable.Delete. Delete in
Delphi should automatically move the record pointer to the next record (I
know for sure that it does in non-xBase databases). You'll also have to
pack your table. There may be an easier way to do that, but the only way I
know of is to use the BDE function DbiPackTable. To see how to use this
you'll need to go to the BDE Online Reference help file - not the regular
Delphi help file.
-Dell
"Bpk. Adi Wira Kusuma" <adi_wira_kusuma (AT) yahoo (DOT) com.sg> wrote
| Quote: | I Use foxpro. My datas have been double. How to delete the data which
double
by quickly? When I index with unique, data just still be double.
How to avoid the data double quickly and precisely?
|
|
|
| Back to top |
|
 |
Bpk. Adi Wira Kusuma Guest
|
Posted: Fri Mar 18, 2005 12:48 am Post subject: Re: How to delete the data which double by quickly? |
|
|
Thanks.
"Dell Stinnett" <dell.stinnett> wrote
| Quote: | Index on your key field(s), non-unique.
sKey := ''; //I'm using a string here - use whatever type your key field
is.
while not tMyTable.eof do
begin
if tMyTable.FieldByName('KEY_FIELD').AsString <> sKey then
begin
sKey := tMyTable.FieldByName('KEY_FIELD').AsString;
tMyTable.Next;
end
else
tMyTable.Delete;
end;
Note that you do NOT do tMyTable.Next after the tMyTable.Delete. Delete
in
Delphi should automatically move the record pointer to the next record (I
know for sure that it does in non-xBase databases). You'll also have to
pack your table. There may be an easier way to do that, but the only way
I
know of is to use the BDE function DbiPackTable. To see how to use this
you'll need to go to the BDE Online Reference help file - not the regular
Delphi help file.
-Dell
"Bpk. Adi Wira Kusuma" <adi_wira_kusuma (AT) yahoo (DOT) com.sg> wrote in message
news:4239caa9 (AT) newsgroups (DOT) borland.com...
I Use foxpro. My datas have been double. How to delete the data which
double
by quickly? When I index with unique, data just still be double.
How to avoid the data double quickly and precisely?
|
|
|
| Back to top |
|
 |
|