Avatar of chainfear

asked on 

Dump Oracle database to CSV using perl DBI

Hi Experts,

I am new to perl. As per title, below is my codes:

use strict;
use warnings;
use DBI;

my $dbh = DBI->connect('dbi:Oracle:host=x.x.x.x;sid=xxxx;port=1521',
               'user', 'pass', { RaiseError => 1, AutoCommit => 0 });

open(my $outputFile, '>', 'file.tsv');
my $sth = $dbh->prepare('SELECT * FROM SCHEMA.TABLE');
my $row;
while ($row = $sth->fetchrow_arrayref)
  print $outputFile join("|", @$row) . "\n";

    $dbh->disconnect if defined($dbh);

Open in new window

I am getting this error:
Use of uninitialized value in join or string at ./q6.pl line 17, which is this line:
print $outputFile join("|", @$row) . "\n";

Open in new window

Any clue?

PerlOracle Database

Avatar of undefined
Last Comment

8/22/2022 - Mon