bluegroper
Technical User
I'm new to perl, and even newer to DBI:Xbase.
Can somebuddy help me with this code sample ?
Yes, its perl for win32.
Just trying to open a .dbf, then for each record, set DATE_COMPL=DATE_SIGN.
The code seems to work on the .dbf, but halts with an error (below).
Also it doesn't print the first 100 records as requested. (That worked in a previous version.)
It seems like the do .. update statement operates on all records at once, rather than working sequentially thru.
So I assume that I need not bother with a record pointer.
I hope someone can help me use the correct logic and syntax.
Error message is
Much TIA's
- BG
Can somebuddy help me with this code sample ?
Yes, its perl for win32.
Just trying to open a .dbf, then for each record, set DATE_COMPL=DATE_SIGN.
The code seems to work on the .dbf, but halts with an error (below).
Also it doesn't print the first 100 records as requested. (That worked in a previous version.)
It seems like the do .. update statement operates on all records at once, rather than working sequentially thru.
So I assume that I need not bother with a record pointer.
I hope someone can help me use the correct logic and syntax.
Code:
#! perl -w
#
# COMPILER DIRECTIVES
#
use strict; use diagnostics; use English;
use DBI;
# VARIABLES
#
my $array;
my (@data, $data);
my $Directory="D:/some/data";
my $dbFile="DATA.DBF";
# SANITY CHECKS
#
my $dbhandle=DBI->connect("DBI:XBase:$Directory") or die $DBI::errstr;
# MAIN
#
my $sthandle1=$dbhandle->prepare("SELECT ID,DATE_SIGN,DATE_COMPL from $dbFile") or die $dbhandle->errstr();
$sthandle1->execute() or die $sthandle1->errstr();
my $sthandle2=$dbhandle->do("UPDATE $dbFile SET DATE_COMPL=DATE_SIGN");
$sthandle2->execute() or die $sthandle2->errstr();
print "ID\t DATE_SIGN\t DATE_COMPL\n";
for (1 .. 100) {
@data=$sthandle1->fetchrow_array();
print "$_\t@data\n";
}
# CLOSURES
#
$dbhandle->disconnect;
exit 0;
# SUBROUTINES
#
Error message is
Code:
Can't call method "execute" without object or package reference at test.pl line 26 (#1)
(F) You used the syntax of a method call, but the slot filled by the object reference or package name contains an expression that returns a defined value that is neither an object reference nor a package name. etc
Much TIA's
- BG