Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Joining two files on common field

by ch1 (Novice)
on Sep 22, 2005 at 22:54 UTC ( [id://494336]=note: print w/replies, xml ) Need Help??


in reply to Re: Joining two files on common field
in thread Joining two files on common field

Here is code but I'm getting an error.
#!/usr/bin/perl -w use DBI; $dbh = DBI->connect("DBI:CSV:f_dir=/home/turn2sp/tmp") or die "Cannot connect: " . $DBI::errstr; $dbh->{'csv_tables'}->{'Matrix'} = { 'file' => 'Matrix.csv'}; $dbh->{'csv_tables'}->{'Inventory'} = { 'file' => 'Inventory.csv'}; $sth = $dbh->prepare("SELECT * from Matrix NATURAL JOIN Inventory"); #$sth = $dbh->prepare("SELECT * FROM Inventory"); $sth->execute(); while ( @row = $sth->fetchrow_array ) { print "@row\n"; }
DBD::CSV::db prepare failed: Parse error near NATURAL JOIN Inventory at /usr/lib/perl5/site_perl/5.8.4/i686-linux/DBD/File.pm line 195. for Statement "SELECT * from Matrix NATURAL JOIN Inventory" at ./j line 7. Can't call method "execute" on an undefined value at ./j line 10.

Replies are listed 'Best First'.
Re^3: Joining two files on common field
by jZed (Prior) on Sep 22, 2005 at 23:00 UTC
      I don't know how to check which version of SQL::Statement I'm using?
        There are several ways.

        At a command prompt (DOS prompt, etc.) type this:

        perl -MSQL::Statement -e "print $SQL::Statement::VERSION"

        Or write a small script like this:

        use SQL::Statement; print $SQL::Statement::VERSION;

        The code you showed should definitely work in any SQL::Statement newer than three or four years old (I should know, I am it's author). So you may be best off to just reinstall it and get a new version. If you keep having problems, post here, don't give up. Good luck!
Re^3: Joining two files on common field
by ikegami (Patriarch) on Sep 23, 2005 at 17:35 UTC
    To get a better error message, change
    $sth = $dbh->prepare("SELECT * from Matrix NATURAL JOIN Inventory");
    to
    $sth = $dbh->prepare("SELECT * from Matrix NATURAL JOIN Inventory") or die "Cannot prepare: " . $DBI::errstr;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-23 14:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found