my $dbh = DBI->connect ("dbi:Oracle:$v_primary_db","username","password",{ RaiseError => 1, AutoCommit => 0, ora_session_mode => ORA_SYSDBA }) || die "Database connection not made: $DBI::errstr"; open (SQL, "$primarysql"); while (my $sqlstatement = ) { $sth = dbi->prepare($sqlstatement); $sth ->execute(); while (my @row = $sth->fetchrow_array() ){ foreach (@row) { $_="\t" if !defined($_); print "$_\t"; } print "\n"; } } END { $dbh->disconnect if defined($dbh); } }