#!/usr/bin/perl -w use strict; use DBI; my $table = shift; my $dbuser = shift; my $dbpass = shift; my $dbname = shift; my $dbd = 'Oracle'; my $dbh = DBI->connect ( $dbname, $dbuser, $dbpass, $dbd); if (!$dbh) { die "$0 Error conecting to DB ($dbuser/$dbpass\@$dbname); $DBI::errstr\n"; } my $SQL = <{LongReadLen} = 65500; my $sth = $dbh->prepare($SQL) || die $dbh->errstr; $sth->execute(); my $colNames = $sth->{'NAME'}; my $nColumns = $sth->{'NUM_OF_FIELDS'}; print <fetchrow_array ) { # print join ( '|', @r ); # This causes another bug of putting 0's where # I wanted || outputted :( # print join ( '|', map ( $_ || '0', trim( @r )) ); # print join ( '|', map ( $_, trim( @r )) ); print "\n"; } $sth->finish || die; $dbh->disconnect; sub trim { my @out = @_; if ( !defined(@_)) {return "";} if ( $#out == -1 ) {return "";} for(@out) { #next if !($_); if (!($_)) { $_ = ""; } s/^\s+//; s/\s+$//; s/\|//g; s/\n//g; s/\cM//g; s/\r//g; } return wantarray ? @out : $out[0]; }