in reply to Problem with DBI, DBD::XBase
Hello Holger,
Running the following code I can see no problems with the years:
use strict; use warnings; use DBI; my $dbf_dir = '.'; my $dbh = DBI->connect("DBI:XBase:$dbf_dir") or die $DBI::errstr; my $def = "CREATE TABLE t_year (cal_year INTEGER)"; unlink 't_year.dbf'; $dbh->do($def); my $sth = $dbh->prepare('INSERT INTO t_year VALUES (?)'); while ( my $year = <DATA> ) { chomp $year; print "Inserting $year\n"; $sth->execute($year) or die $sth->errstr(); } my $sth2 = $dbh->prepare("select cal_year from t_year") or die $dbh->errstr(); $sth2->execute() or die $sth2->errstr(); while ( my @rec = $sth2->fetchrow_array() ) { print "Extracting @rec\n"; } $dbh->disconnect(); __END__ 1990 2000 2010
My output is as expected:
Inserting 1990 Inserting 2000 Inserting 2010 Extracting 1990 Extracting 2000 Extracting 2010
What is the structure of your table?
Regards, Stefan
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Problem with DBI, DBD::XBase
by hgtmp (Initiate) on Jan 21, 2013 at 08:54 UTC | |
by stefbv (Curate) on Jan 21, 2013 at 10:52 UTC | |
by hgtmp (Initiate) on Jan 22, 2013 at 08:57 UTC | |
by stefbv (Curate) on Jan 22, 2013 at 16:08 UTC | |
by hgtmp (Initiate) on Jan 24, 2013 at 15:06 UTC | |
|
In Section
Seekers of Perl Wisdom