ERROR:
C:\Perl\Perlscripts>dumplog.pl "Controller - 20030721" DBD::XBase::db prepare failed: Extra characters in SQL command near `- 20030721' at C:\Perl\Perlscripts\dumplog.pl line 44. Can't call method "execute" on an undefined value at C:\Perl\Perlscripts\dumplog .pl line 45.
#Libraries # DBI is the Data base Interface it uses a module DBD::XBase # to access Foxpro database files. # # use DBI; my $basedir = "G:/"; my $logdir = "LOGS"; read_log ( shift ); sub read_log (@){ my $log = join '',@_; my $href = get_columns ($log); my $logref = get_log_dump($log); print " Confirm ". @$logref. " records \n"; print "Dumping Log ".$basedir.$logdir."/$log\n"; foreach $field ( @$href ) { print "$field\t"; } print "\n###################################################\n"; foreach my $log_row ( @$logref){ foreach my $log_entry (@$log_row) { print "$log_entry\t"; } print "\n"; } } sub get_columns ($) { my $log = shift; my @Cols = (); my $dbobject = DBI->connect("DBI:XBase:".$basedir.$logdir) or die $DBI::errstr; # sth is used for the variable it means statement handle my $sql = "SELECT * FROM $log"; $sth = $dbobject->prepare($sql); $sth->execute(); for ( $i = 1; $i <= $sth->{NUM_OF_FIELDS}; $i++){ push @Cols, $sth->{NAME}->[$i-1]; } $dbobject->disconnect(); return \@Cols } sub get_log_dump ($) { my $log = shift; my $dbobject = DBI->connect("DBI:XBase:".$basedir.$logdir) or die $DBI::errstr; $sth = $dbobject->prepare("SELECT * FROM $log"); $sth->execute(); my $resultref = $sth->fetchall_arrayref(); print "Retrieved ". @$resultref ." records\n"; return $resultref; }
In reply to DBI Long File names? by talwyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |