#!perl -w ######################################################### # This perl script will go to the oracle database, run a query, extract data and # create a text (.txt) file with data information for a batch # process to use. # # ######################################################### use DBI; # output file $newfile = ">./batch_test.txt"; # open the new .txt file open(BATCH, "$newfile") || die "Can't open $newfile : the batch_test file. $!"; # initialize variables # variable with query to get data from admin.batch_lines table $asql = "SELECT batch_line FROM admin.batch_lines"; # connect to oracle my $dbh = DBI->connect("dbi:Oracle:D001", "develop", "developerPW"); my $statement = $dbh->prepare($asql); $statement ->execute(); while ($newfile= $statement->fetchrow_array) { # remove the all leading 'D:' in the file $newfile=~s/D://g; # shows the correct data print $newfile; print "\n"; } # close oracle connection $statement->finish(); $dbh->disconnect(); # close new .txt file close (BATCH);