in reply to Re: One Question about DBF
in thread One Question about DBF

Hello jZed
I try you code and put what a like to think are the correct parameters and did not work :o(
Ok I am going very level with you I just need to get all data from a DBF table and put it in a CSV file
here you can look at my code and please tell me what is wrong
thanks
use DBI; my $dbhX = DBI->connect("DBI:XBase:/proyecto"); my $dbhA = DBI->connect( 'dbi:AnyData:' ); my $sth = $dbhX->prepare("SELECT * FROM reg501"); $sth->execute(); $dbhA->do("CREATE TABLE etstx AS SELECT * FROM ?",{}, $sth);
TIA

Replies are listed 'Best First'.
Re^3: One Question about DBF
by jZed (Prior) on Oct 18, 2007 at 18:48 UTC
    Oh, sorry, yeah, after the $dbhA line put this:
    $dbhA->ad_catalog('etstx','CSV','etstx.csv');
    The first param is the table name to use in your SQL, the second the format of the file the table will be stored in, the third the path/filename of the file.

    update : added the missing ad_

      Hi jZed!
      I added the line as you told me but it gave me these error
      Can't locate object method "catalog" via package "DBI::db" at testdbf.pl line 5.
      This is the code
      use DBI; my $dbhX = DBI->connect("DBI:XBase:/proyecto"); my $dbhA = DBI->connect( 'dbi:AnyData:' ); $dbhA->catalog('etstx','CSV','etstx.csv'); my $sth = $dbhX->prepare("SELECT * FROM reg501"); $sth->execute(); $dbhA->do("CREATE TABLE etstx AS SELECT * FROM ?",{}, $sth);
        Sorry again, not enough coffee this morning - should be $dbh->ad_catalog().