Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Problem with DBI, DBD::XBase

by stefbv (Chaplain)
on Jan 19, 2013 at 09:48 UTC ( #1014192=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Problem with DBI, DBD::XBase
Select or Download Code
Re^2: Problem with DBI, DBD::XBase
by hgtmp (Initiate) on Jan 21, 2013 at 08:54 UTC
    Hi Stefan.
    I can reproduce your small example and get the years too.
    So I think it is a problem with my DEF-file.
    The DEF-file is created by an external process.
    I am new here. Can I upload a small file?
    Many thanks for your comment, Holger

      Hi Holger,

      You can't upload, but if it's a text file, you can put it's contents here between code tags.

      Stefan

        Hi Stefan.
        I would like to upload the DBF-file which is a binary.
        Do you know a validator for DBF files?
        Thanks in advance, Holger

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (18)
As of 2014-07-31 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls