I have searched online for several days and cannot find an answer.
Does Perl DBI support Oracle Subquery Factoring (i.e. WITH-clause)?
As an example, the simple Perl DBI application further below fails with the error:
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first)
Simple Perl DBI Application:
#!/bin/perl
use DBI;
my $sql = <<END_SQL;
WITH w AS
(
SELECT wafer_seq
FROM wafer
WHERE load_time > sysdate - 1
)
SELECT v.*
FROM vwafer v, w
WHERE v.wafer_seq = w.wafer_seq
ORDER BY v.wafer_seq
END_SQL
my $dbh = DBI->connect('DBI:Oracle:<schema_id>', '<username>', '<password>');
my $sth = $dbh->prepare($sql) || die "ERROR PREP";
$sth->execute() || die "ERROR EXEC";
while (my @row = $sth->fetchrow_array())
{
print "@row\n";
}
$sth->finish();
$dbh->disconnect();
exit 0;
This same application will work if I simply change the SQL to:
SELECT v.*
FROM vwafer v,
(
SELECT wafer_seq
FROM wafer
WHERE load_time > sysdate - 1
) w
WHERE v.wafer_seq = w.wafer_seq
ORDER BY v.wafer_seq
Finally, I confirmed that both SQLs mentioned above work when executed directly in a database visualizer application (e.g. DBVisualizer).
It appears my version of Perl (5.8.8), DBI (1.58), and/or DBD::Oracle (1.19) do not support Oracle Subquery Factoring.
I was able to successfully execute the same Perl application through updated Perl (5.12.1), DBI (1.613), and DBD::Oracle (1.24) versions.
Unfortunately, even after reading change histories for Perl, DBI, and DBD::Oracle, I do not know exactly which component introduced support of Oracle Subquery Factoring. My suspicion is the DBI Oracle driver (DBD::Oracle).