Sorry if I posted this twice - I did not see my first post go through.
I am trying to do a join across to csv files but have been unsuccessful
up to this point.
I have two tables:
tab1.csv
TAB_ONE_ID,NAME,TAB_TWO_ID
1,row1,100
2,row2,200
tab2.csv
TAB_TWO_ID,CATEGORY
100,cat1
200,cat2
I am running the following query:
select TAB_ONE.NAME,TAB_TWO.CATEGORY
from TAB_ONE, TAB_TWO
where TAB_ONE.TAB_TWO_ID = TAB_TWO.TAB_TWO_ID
I expect the following:
row1, cat1
row2, cat2
I get the following:
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 553, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 553, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 553, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 554, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 554, <GEN1> line 1.
Use of uninitialized value in string eq at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 556, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 560, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 560, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 560, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 562, <GEN1> line 1.
Use of uninitialized value in concatenation (.) or string at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 562, <GEN1> line 1.
Use of uninitialized value in array element at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 891, <GEN0> line 3.
Use of uninitialized value in array element at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 891, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
Use of uninitialized value in array slice at
/usr/local/share/perl/5.8.4/SQL/Statement.pm line 898, <GEN0> line 3.
1, 1
1, 1
2, 2
2, 2
platform:
OS: Linux 2.6.8-1-686 #1 Thu Nov 25 04:34:30 UTC 2004 GNU/Linux
Perl: This is perl, v5.8.4 built for i386-linux-thread-mult
DBD::CSV: 0.21
SQL::Statement: 1.09
here is the script
--- snip ---
#! /usr/bin/perl -w
use DBI;
$dbh = DBI->connect("DBI:CSV:f_dir='.'",
{'select' => {'join' => 1}})
or die "Cannot connect: " . $DBI::errstr;
$dbh->{'csv_tables'}->{'TAB_ONE'} = { 'file' => 'tab1.csv'};
$dbh->{'csv_tables'}->{'TAB_TWO'} = { 'file' => 'tab2.csv'};
$dbh->{'csv_eol'} = "\n";
my $sth = $dbh->prepare("select TAB_ONE.NAME,TAB_TWO.CATEGORY
from TAB_ONE, TAB_TWO
where TAB_ONE.TAB_TWO_ID =
TAB_TWO.TAB_TWO_ID");
$sth->execute();
while ( @row = $sth->fetchrow_array ) {
$row[length @row] = '' if(! defined $row[length @row]);
print join(', ', @row), "\n";
}
$sth->finish();
$dbh->disconnect();
--- snip ---
Can anyone help me.