I am having a problem with associated tables using the BerkeleyDB module. Here is a snippet of code:
The key_sub extracts one field from the record using split, and I want to use that as a secondary index. I have no error messages when the first record is inserted, but when I insert a second record, I get error messages that indicate that the numeric comparison function, and not the ascii comparison function, is being used for the secondary table.my $table = BerkeleyDB::Btree->new( -Filename => "$home/$tableName/$tableName", -Compare => sub { my($a, $b) = @_; return $a <=> $b; }, # numeric -Flags => DB_CREATE, ) or die "Could not open \'$home/$tableName/$tableName\' ... "; my $db = BerkeleyDB::Btree->new( -Property => DB_DUP, -Flags => DB_CREATE, -Filename => "$home/$tableName/$dbName", -Compare => sub { my($a, $b) = @_; return $a cmp $b; }, # ascii ) or die "Could not open \'$home/$tableName/$dbName\' ... "; $table->associate($db, \&key_sub);
The line number in the error messages above is the line where the numeric comparison is defined. Is this a bug in the perl BerkeleyDB module, or is it a bug in the db library itself? Is there a work-around for it? Thanks for your help.Argument "w61" isn't numeric in numeric comparison (<=>) at /home/Acct +Table.pm line 80. Argument "w60" isn't numeric in numeric comparison (<=>) at /home/Acct +Table.pm line 80.
In reply to Associated BerkeleyDB table uses wrong compare? by tall_man
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |