$ cat file_01.csv
Prefix,NumberRange,Chargeband
pfx,1,4
$ qs f file_01
SCHEMA: merijn, TABLE: file_01
[/pro/3gl/CPAN/DBD-CSV/sandbox]
select prefix, numberrange, chargeband
from file_01
prefix|numberrange|chargeband
------------------------------
pfx |1 |4
$ cat file_02.csv
Termination,Service,ChargeBand
end,yes,4
$ qs f file_02
SCHEMA: merijn, TABLE: file_02
[/pro/3gl/CPAN/DBD-CSV/sandbox]
select termination, service, chargeband
from file_02
termination|service|chargeband
-------------------------------
end |yes |4
$
####
$ cat inner.pl
#!/pro/bin/perl
use strict;
use warnings;
use DBI;
my $dir = ".";
my $eol = "\n";
my $sep = ",";
my $dbh_match = DBI->connect ("dbi:CSV:", undef, undef, {
f_dir => $dir,
f_ext => ".csv/r",
csv_eol => $eol,
csv_sep_char => $sep,
RaiseError => 1,
PrintError => 1,
}) or die "Cannot connect: " . $DBI::errstr;
print STDERR "Using perl version $]\n";
print STDERR "Using DBI version $DBI::VERSION\n";
print STDERR "Using DBD::File version $DBD::File::VERSION\n";
print STDERR "Using SQL::Statement version $SQL::Statement::VERSION\n";
print STDERR "Using Text::CSV_XS version $Text::CSV_XS::VERSION\n";
my $sth_match = $dbh_match->prepare (qq;
CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange,
file_02.Termination, file_02.Service, file_02.ChargeBand
FROM file_01 INNER JOIN file_02
ON file_01.Chargeband = file_02.ChargeBand
WHERE file_02.Termination LIKE 'something';
);
$sth_match->execute or die "Cannot execute: " . $sth_match->errstr ();
DBI->trace (1);
$dbh_match->disconnect;
##
##
$ perl inner.pl
Using perl version 5.014001
Using DBI version 1.616
Using DBD::File version 0.40
Using SQL::Statement version 1.33
Using Text::CSV_XS version 0.82
DBD::CSV::st execute failed: You passed 0 parameters where 1 required [for Statement "
CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange,
file_02.Termination, file_02.Service, file_02.ChargeBand
FROM file_01 INNER JOIN file_02
ON file_01.Chargeband = file_02.ChargeBand
WHERE file_02.Termination LIKE 'something'"] at inner.pl line 33.
DBD::CSV::st execute failed: You passed 0 parameters where 1 required [for Statement "
CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange,
file_02.Termination, file_02.Service, file_02.ChargeBand
FROM file_01 INNER JOIN file_02
ON file_01.Chargeband = file_02.ChargeBand
WHERE file_02.Termination LIKE 'something'"] at inner.pl line 33.
Exit 22
$