Re: DBD::CSV and multiple table queries

2002-10-26 Thread Scott McGee
Jeff Zucker [EMAIL PROTECTED] wrote in message
news:3DB98694.8080701;vpservices.com...
 Yes, there is a bug in SQL::Statement related to table names combined with
a column name (e.g. megaliths.id).

 I will be releasing a fix later today.

Thank you oh great and wise one! I appreciate the help and the speed of it
too!

Scott





Re: DBD::CSV and multiple table queries

2002-10-25 Thread nhendler
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




Re: DBD::CSV and multiple table queries

2002-10-25 Thread Scott McGee
[EMAIL PROTECTED] wrote in message
news:1842904766.20021025094128;comcast.net...
 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.

No, the above is a typo. It should read megalith not magalith. In truth, I
had it as undef in the script I ran and had an environment variable
(DBI_DSN) set to handle it. I used the same script successfully by just
changing the SELECT statement so I am positive that the problem is in the
modules being used somewhere.

Scott





Re: DBD::CSV and multiple table queries

2002-10-25 Thread Jeff Zucker
Scott McGee wrote:


  SQL::Parser v1.004
  SQL::Statement v1.004


 ...


my $query = SELECT megaliths.id, megaliths.name, site_types.site_type



Yes, there is a bug in SQL::Statement related to table names combined with a column name (e.g. megaliths.id).


I will be releasing a fix later today.


--
Jeff






Re: DBD::CSV and multiple table queries

2002-10-25 Thread John

On Friday, October 25, 2002 11:01 PM [GMT + 10:00 AEST],
Scott McGee [EMAIL PROTECTED] wrote:

 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

As an alternative to DBD::CSV have you considered DBD::SQLite for your
situation. SQLite is public domain, DBD::SQLite includes the entire
thing in the distribution.


--
Regards
   John McMahon  (mailto:jmcm;bendigo.net.au)