It appears from the error message that it cannot locate the CSV file
at all.  Are you sure:

$dbd = "DBI:CSV:f_dir=magalith_db";

Is correct?  You've spelled 'megalith' as 'magalith'.  Just have to
check.  I assume you've got whatever dir on the same level as your
script and that you've got a file named megaliths.csv in that dir.


 
Nick Hendler
[EMAIL PROTECTED]

_________________________________________

From:    Scott McGee <[EMAIL PROTECTED]>
Date:    Friday, October 25, 2002 
Time:    9:01:08 AM
Subject: DBD::CSV and multiple table queries

I am trying to get comfortable with DBI, and due to stupid circumstances
beyond my control at the moment, have to try to make do without an actual
database server. This means using something like DBD::CSV. I am just trying
to go through the O'Reilly Perl DBI book, so don't need anything too complex

I have found, however, that I cannot do a SELECT over multiple tables. The
documentation seems to indicate that I should be able to.

I have checked all the software, and it is up to date:
  perl v5.8.0
  DBI v1.30
  DBD::CSV v0.2002
  SQL::Parser v1.004
  SQL::Statement v1.004
  (I did find an older version of CSV, but got rid of it)
I am running under Solaris 8 on a SPARCstation 5. (Yes, there are DB servers
for it, but I don't have disk space!)

The error I get is:

Execution Error: No such column 'MEGALITHS.ID' called from query2 at 23.

The program (query2) looks like this:

<-- begin included file query2 -->
#!/usr/bin/perl -w

use DBI;            # Load the DBI module

$dbd = "DBI:CSV:f_dir=magalith_db";
$login = undef;
$passwd = undef;

### Perform the connection using the Oracle driver
my $dbh = DBI->connect( $dbd, $login, $passwd );
$dbh->{'RaiseError'} = 1; # turn off die() on error
$dbh->{'PrintError'} = 1; # turn off warn() on error

### create the megaliths table
my $query = "SELECT megaliths.id, megaliths.name, site_types.site_type
             FROM megaliths, site_types
             WHERE megaliths.site_type_id = site_types.id
             ";
$sth = $dbh->prepare($query )
    || die "Dude! This sucker failed! : $sth->errstr()\n";
$sth->execute();
#while (my $row = $sth->fetchrow_hashref) {
#    print("Found result row: id = ", $row->{'id'},
#          ", name = ", $row->{'name'}, ", site_type = ",
#          $row->{'site_type'}, "\n");
#}

while ( my @row = $sth->fetchrow_array() ) {
    print "row: @row\n";
}


### Disconnect from the database
$dbh->disconnect;

exit;
<-- end included file query2 -->

If anyone can help, I would greatly appreciate it.

Scott

Reply via email to