use strict;
use warnings;
use DBI;
# change $out_file to whatever path/name you want
my $out_file = 'output.csv';
open OUT, '>', $out_file or die "could not write $out_file: $!";
# lookup the DBD::Oracle docs for the correct connection string
my $dbh = DBI->connect(...);
# you need to change the query to what you want
my $sql = 'select col1, col2, col3 from table where x = y';
my $sth = $dbh->prepare($sql);
$sth->execute;
while (my $row = $sth->fetchrow_arrayref) {
print OUT join(',', map { s{"}{""}g; "\"$_\""; } @$row), "\n";
}
$sth->finish;
$dbh->disconnect;
|