#!/...path...to...desired...version...of.../perl use strict; use warnings; use DBI; # Load the DBI module ### Attributes to pass to DBI->connect() to disable automatic error checking my %attr = ( PrintError => 0, RaiseError => 0, ); ### Connect using the Oracle driver my $dbh = DBI->connect("DBI:Oracle:", "user", "password", \%attr ) or die "Can't connect to database: ", $DBI::errstr, "\n"; ### Be prepared for long fields $dbh->{LongReadLen} = 100000; ### Prepare the SQL statement for execution my $sth = $dbh->prepare( "$ARGV[0]" ) or die "Can't prepare SQL statement: ", $dbh->errstr(), "\n"; ### Execute the statement in the database $sth->execute or die "Can't execute SQL statement: ", $sth->errstr(), "\n"; ### Retrieve the returned rows of data my @row; while ( @row = $sth->fetchrow_array() ) { print @row, "\n"; } warn "Problem in fetchrow_array(): ", $sth->errstr(), "\n" if $sth->err(); $sth->finish; ### Disconnect from the database $dbh->disconnect or warn "Failed to disconnect: ", $dbh->errstr(), "\n"; exit;