[ic] searching index file

Scott Andreas interchange-users@interchange.redhat.com
Tue Apr 2 14:42:01 2002


Hello list,

Well here it is, I'm connecting to our live data via ncpfs (netware) and
reading the data via DBD::XBase ( a DBI driver) but the searches are
increadibly sloooow. Upon further investigation it would seem that I should
be searching the index file (ours used a compound index file .cdx). With in
the DBD::XBase perl module are submodules (XBase, XBase::memo, XBase::Index,
XBase::Base, and XBase SDBM) and to use the XBase::Index module I would
write my perl like such...

use XBase;
my $table = new XBase "data.dbf"; <----db to return fields from
my $cursor = $table->prepare_select_with_index([data.cdx', "tag_name"],
"list", "of", "fields", "to", "return");
$cur->find_eq(searchvalue);


#this is where my brain goes into fuzzy logic mode

while (my $hashref = $cur->fetch_hashref and $hashref->{"ID"} ==
searchvalue) {
###do something here with $hashref
}

So if I want to bind IC code with this perl object and output the reuslts
with IC tags what would I need to do....



Also If my reading of the docs are correct and I want to use the perl tag I
would do something like...

[perl global=1 subs=1 tables =arinv01]
use XBase;
my $table = new XBase "arinv01.dbf";
my $cursor = $table->prepare_select_with_index([arinv01.cdx', "FINVNO"],
"FINVNO", "FCOMPANY", FPONO, FSONO, FCUSTNO, FHIPDATE
$cur->find_eq(1097);

while (my $hashref = $cur->fetch_hashref and $hashref->{"FINVNO"} == 1097) {
###do something here with $hashref
}

return;
[/perl]

In interchange.cfg I would set
AllowGlobal catalogname

According to the XBase synopsis

=head2 Sequentially reading the file

If you plan to sequentially walk through the file, you can create
a cursor first and then repeatedly call B<fetch> to get next record.

=over 4

=item prepare_select

As parameters, pass list of field names to return, if no parameters,
the following B<fetch> will return all fields.

=item prepare_select_with_index

The first parameter is the file name of the index file, the rest is
as above. For index types that can hold more index structures in on
file, use arrayref instead of the file name and in that array include
file name and the tag name, and optionaly the index type.
The B<fetch> will then return records in the ascending order,
according to the index.

=back

Prepare will return object cursor, the following method are methods of
the cursor, not of the table.

=over 4

=item fetch

Returns the fields of the next available undeleted record. The list
thus doesn't contain the C<_DELETED> flag since you are guaranteed
that the record is not deleted.

=item fetch_hashref

Returns a hash reference of fields for the next non deleted record.

=item last_fetched

Returns the number of the record last fetched.

=item find_eq

This only works with cursor created via B<prepare_select_with_index>.
Will roll to the first record what is equal to specified argument, or
to the first greater if there is none equal. The following B<fetch>es
then continue normally.

=back





It would be nice to create a usertag....any help on that would be great




Any info on what I need to do would be great

ThxNAdv.

Scott


J. Scott Andreas :)
IS/Programmer/WebDevelopement
Learning Services, Inc.
e-mail: sandreas@learningservicesinc.com
phone: 1-800-877-9378 ext. 146
fax: (541) 744-2056

       ---    __o
     ---   _-\<,_
      --- (_)/ (_)