talwyn has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Long File names?
by waswas-fng (Curate) on Sep 29, 2003 at 19:46 UTC | |
by talwyn (Monk) on Sep 30, 2003 at 13:39 UTC | |
by hmerrill (Friar) on Sep 29, 2003 at 20:58 UTC | |
by talwyn (Monk) on Sep 30, 2003 at 13:46 UTC | |
|
Re: DBI Long File names?
by hmerrill (Friar) on Sep 29, 2003 at 19:45 UTC | |
by talwyn (Monk) on Sep 29, 2003 at 21:50 UTC | |
|
Re: DBI Long File names?
by flounder99 (Friar) on Sep 29, 2003 at 19:48 UTC | |
by talwyn (Monk) on Sep 29, 2003 at 21:44 UTC | |
by iburrell (Chaplain) on Sep 30, 2003 at 17:22 UTC | |
by talwyn (Monk) on Oct 06, 2003 at 18:52 UTC | |
by talwyn (Monk) on Oct 02, 2003 at 15:07 UTC |