【发布时间】:2014-01-27 22:20:47
【问题描述】:
我正在尝试使用DBI 中的UNION 语句来合并两个CSV 文件:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect ("dbi:CSV:")
or die "Cannot connect to the CSV file: $DBI::errstr()";
$dbh->{RaiseError} = 1;
$dbh->{TraceLevel} = 0;
my $query = "select * from file.csv UNION select * from output.csv";
my $sth = $dbh->prepare ($query);
$sth->execute ();
$sth->dump_results();
$sth->finish();
$dbh->disconnect();
但是,我收到以下错误:
在 FROM 子句中找不到表名!在 C:/Perl64/site/lib/SQL/Statement.pm 第 88 行。
DBD::CSV::db 准备 失败:在 FROM 子句中找不到表名!在 C:/Perl64 /site/lib/SQL/Statement.pm 第 88 行。
[for Statement "select * from file.csv UNION select * from output.csv"] at CSV.pl 第 15 行。
DBD::CSV::db 准备失败:在 FROM 子句中找不到表名!在 C:/Perl64 /site/lib/SQL/Statement.pm 第 88 行。
[for Statement "select * from file.csv UNION select * from output.csv"] at CSV.pl line 15.
我按照其他地方的建议更新了SQL::Statement 和SQL::Parse,但这并没有解决问题。我在 Windows 8.1 上运行。是什么导致了错误?
【问题讨论】: