Please look for script. Output:
# perl CSVtester.pl
Statement 1 did work!
DBD::CSV::st execute failed: Can't call method "column" on an undefined
value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN2> line 1.
[for Statement "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE
REGEX(id,'//i') IS TRUE"] at CSVtester.pl line 28.
Statement 2 did NOT work: Can't call method "column" on an undefined
value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN2> line 1.
#
#!/usr/bin/perl
use DBI;
use DBD::CSV;
use strict;
my $i = 0;
open(NIX, ">", "/tmp/logfile") || die("Unable to /tmp: ".$!);
print NIX "1\n";
close NIX;
open(NIX, ">", "/tmp/certs") || die("Unable to /tmp: ".$!);
print NIX "1\n";
close NIX;
my $dbm = DBI->connect("DBI:CSV:", undef, undef, { csv_class => "Text::CSV_XS"});
$dbm->{csv_tables}->{logfile} = {
f_dir => "/",
file => "/tmp/logfile",
col_names => ["id"]
};
$dbm->{csv_tables}->{certs} = {
f_dir => "/",
file => "/tmp/certs",
col_names => ["id"]
};
foreach my $statement ("SELECT MAX(logfile.id) AS MAX_id FROM logfile LEFT JOIN certs ON certs.id=logfile.id WHERE REGEX(id,'//i') IS TRUE", "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE") {
my $sth = $dbm->prepare($statement);
$sth->execute();
syswrite(STDOUT, "Statement ".++$i." did ".($@ ? "NOT work: ".$@ : "work!")."\n");
}