RE: DBI:CSV join ... flashback to 2002



Another way to remove the dot in the query is as follows.

$dbh->{'csv_tables'}->{table_a} = { 'file' => table_a.csv };
$dbh->{'csv_tables'}->{table_b} = { 'file' => table_b.csv };

$sth = $dbh->prepare("Select a.subject from table_a as a, table_b as b
where a.subject=b.subject");

I haven't verified it will resolve your issue, but if it works for you,
you don't have to rename all your files.


Good luck,

Curtis


-----Original Message-----
From: Robert Roggenbuck [mailto:rroggenb@xxxxxxxxxxxxxxxxxxxxxxxxxxxx]
Sent: Monday, July 16, 2007 8:25 AM
To: ballard.d@xxxxxxxxx
Cc: dbi-users@xxxxxxxx
Subject: Re: DBI:CSV join ... flashback to 2002

The problem seems to be the dot in the table names. The dot have special
meanings in SQL for table names and is not just an allowed character
(for example it is used as scheme separator 'scheme.tablename'). Just
try to rename Your CSV-files by cutting of the extension '.csv'. May be
all the problems will be gone then.

Best regrads

Robert

----

ballard.d@xxxxxxxxx schrieb:
Question about joining using DBI:CSV. I must be making a stupid
mistake somewhere.

Earlier posts (2002) state that there were problems using aliases in
joins. I've just installed the modules on a windows machine and am
having the same problems.
DBI (v1.58)
SQL-Statement(v1.15)
Text-CSV_XS(v.3)
DBD-CSV(v.22)
DBD-File(v.35)

Running a simple query with no aliases works.

When I run the same query with an alias i get an error message
(below). However, the error message is followed by the correct query
results.

$sth = $dbh->prepare("Select b.subject from table_b.csv as b"); $sth =

$dbh->prepare("Select a.subject from table_a.csv as a");
SQL ERROR: Table 'CSV' referenced but not found in FROM list!


I then tried a simple join (using where a.subject=b.subject). I get
the error referenced in previous posts.

$sth = $dbh->prepare("Select a.subject from table_a.csv as a,
table_b.csv as b where a.subject=b.subject");
DBD::CSV::st execute failed: Can't call method "col_names" on
unblessed reference at c:\perl\site\lib\SQL\Statement.pm line 610, <GEN>
line 1.
[for Statement "Select a.subject from table_a.csv as a, table_b.csv as

b where a.subject=b.subject"] at temp.pl line 14


I then tried using the join syntax instead of the WHERE statement as
suggested in the previous post, but i get an error message

$sth = $dbh->prepare("Select * from table_a.csv natural join
table_b.csv");
SQL ERROR: Couldn't parse the explicit JOIN!

table_a.csv
-----------------
chromosome,snp,subject,xx
1,rs1203,102,A
1,rs1203,1025,A
1,rs1203,1034,A
1,rs1203,1078,A

table_b.csv
-----------------
subject
102
1025
1034


If anyone has any suggestions, please let me know. I would greatly
appreciate it.

cheers,
david






.



Relevant Pages

  • Re: DBI:CSV join ... flashback to 2002
    ... The dot have special meanings in SQL for table names and is not just an allowed character. ... Running a simple query with no aliases works. ... When I run the same query with an alias i get an error message ... the error referenced in previous posts. ...
    (perl.dbi.users)
  • DBI:CSV join ... flashback to 2002
    ... Running a simple query with no aliases works. ... When I run the same query with an alias i get an error message ... the error referenced in previous posts. ...
    (perl.dbi.users)
  • Re: query that runs two variables
    ... suggestion into the query and modified the column headers ... to match the table it gave me an error message that I was ... or .(dot) or illegal use of a parenthesis ... >> is missing, subsituting the current date. ...
    (microsoft.public.access.queries)
  • Re: OutputTo to Excel question
    ... I can't help you with the macro error message as I don't use macros. ... the result from a query. ... Save a query that pulls the same data as the report. ...
    (microsoft.public.access.macros)
  • Re: Background Web Queries flaws!
    ... There is no way to trap errors on a background query. ... There is no way to control the timeout setting. ... The basic problem is that IE spits an error message before returning control ... > hard coded a 5 minute limit into the web query system. ...
    (microsoft.public.excel.programming)