So I could run your sample code I added a little code at the start:
...
use DBI;
unlink 'file_01.csv';
unlink 'file_02.csv';
unlink 'new.csv';
open my $oFile, '>', 'file_01.csv';
print $oFile "Prefix,NumberRange,ChargeBand\n";
close $oFile;
open $oFile, '>', 'file_02.csv';
print $oFile "Termination,Service,ChargeBand\n";
close $oFile;
my $dir = '.';
...
) or die "Cannot connect: " . $DBI::errstr;
print "DBI version: $DBI::VERSION\n";
print "DBD::CSV version: $DBD::CSV::VERSION\n";
print "SQL::Statement version: $SQL::Statement::VERSION\n";
my $sth_match = $dbh_match->prepare(
...
and got the following:
DBI version: 1.607
DBD::CSV version: 0.22
SQL::Statement version: 1.15
Use of uninitialized value in substitution iterator at C:/Perl/lib/SQL
+/Parser.pm line 1596.
DBI 1.607-ithread default trace level set to 0x0/1 (pid 4280) at n
+oname1.pl line 48
<- disconnect= 1 at noname1.pl line 50
<- DESTROY(DBI::st=HASH(3c13f34))= ''
<- DESTROY(DBI::db=HASH(3c12a54))= ''
<- disconnect_all= undef at DBI.pm line 717
! <- DESTROY(DBI::dr=HASH(3c124c4))= undef during global destruction
I'm using Perl 5.10.1 from ActiveState and after updating to the 'current' versions of the mentioned modules obtained:
DBI version: 1.616
DBD::CSV version: 0.31
SQL::Statement version: 1.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.ChargeBa
+nd
FROM file_01 INNER JOIN file_02
ON file_01.Chargeband = file_02.ChargeBand
WHERE file_02.Termination LIKE '%something%'
"] at C:\Users\Peter\Delme~~\PerlScratch\noname1.pl line 46.
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.ChargeBa
+nd
FROM file_01 INNER JOIN file_02
ON file_01.Chargeband = file_02.ChargeBand
WHERE file_02.Termination LIKE '%something%'
"] at C:\Users\Peter\Delme~~\PerlScratch\noname1.pl line 46.
which starts to look like a bug introduced or revealed in the process of fixing another bug.
Interestingly switching to use a place holder in the like:
...
WHERE file_02.Termination LIKE ?
|
);
$sth_match->execute('%something%')
or die "Cannot execute: " . $sth_match->errstr();
DBI->trace(1);
...
generates the same error!
True laziness is hard work