[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coldsync-hackers] comparing pdb->DBF (4000 records)



Hi.
I'm not sure if I adress this question right.
I have to compare pdb file with dbf file. DB contains about 4000 records.
I'm doing it in perl,using XBase module and Palm::PDB.
The point is to make pdb have the same records as dbf, (dbf sometimes 
changes,pdb never).

Here is my algorithm:

1 I walk through dbf ,look for  correspond record in pdb. If  I find 
one,check if it was changed.If don't find one I add the record from dbf 
to pdb.
2 Then I have to walk through pdb looking for correspond record in dbf. 
If I don't find one I have to delete it from pdb.

First step takes reasonable time (3 min)
The second one takes not reasonable time.

Here is my code;
  my $cennik2=new XBase "cennik" or die "450 Nie przygotowano nowych 
towarow 2!\n";
  my $it2=0;  my @data;  my $it1;  my $it3=0;  my $it4;
  my 
($id_tow,$nazwa,$skrot,$vat_grupa,$jm,$szt_op,$cena_s2,$cena_n2,$stan2,$skrotp,$nic,$sww);
  foreach(@{$PDB->{"records"}})
    {
    $found="false";
    $it3=0;
    $it4=$cennik2->last_record;
    
($id_tow,$nazwa,$skrot,$vat_grupa,$jm,$szt_op,$cena_s2,$cena_n2,$stan2,$skrotp,$nic,$sww)=unpack("a15 
a40 a15 n a4 N N N N a20 a a15",$_->{data});
    $id_tow=&Polish2($id_tow);$it1=index($id_tow,"\000");
    if($it1 != -1) {$id_tow=substr($id_tow,0,$it1);}
#    $cursor=$cennik2->prepare_select();   
    for($it3;$it3<$it4;$it3++)
    {
        @data=$cennik2->get_record($it3,"ID_TOW");
#        print STDERR (@data,"\n");
    if($id_tow eq $data[1])
        {
        $found="true";
        last;
        }
    }
    if($found ne "true")
    {
    $PDB->delete_Record($_,"true");
    print DIFF "-",$data[1],"\n";
    }       
    print STDERR $it2++,"\n";
    }        
  $cennik2->close();




This message was sent through the coldsync-hackers mailing list.  To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body.  For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.