Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Problem with DBI, DBD::XBase

by stefbv (Deacon)
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
Replies are listed 'Best First'.
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.


        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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2015-11-28 08:41 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (740 votes), past polls