Zo has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone.
I have a problem that might be very simple, I'm probably forgetting/overlooking the obvious... but here I am. I want to connect to an Oracle 8i database, extract a table's data and save the information as a text file on my computer. Simple it seems, but I think I'm missing something.
In the code, I do make a connection, I do get the proper query and info from viewing it scroll up on my prompt from the 'print' statements that I have, but it doesn't want to write it to the file that I want to create. My desktop is running the latest version of ActivePerl I just downloaded recently and of the DBI-1.2 module. My desktop platform is Windows 2000 professional. (if you need any of this information).
What am I missing, doing wrong? Thanks in advance for any/all help!
Brother Zo.
I have a problem that might be very simple, I'm probably forgetting/overlooking the obvious... but here I am. I want to connect to an Oracle 8i database, extract a table's data and save the information as a text file on my computer. Simple it seems, but I think I'm missing something.
In the code, I do make a connection, I do get the proper query and info from viewing it scroll up on my prompt from the 'print' statements that I have, but it doesn't want to write it to the file that I want to create. My desktop is running the latest version of ActivePerl I just downloaded recently and of the DBI-1.2 module. My desktop platform is Windows 2000 professional. (if you need any of this information).
#!perl -w ######################################################### # This perl script will go to the oracle database, run a query, extrac +t 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 f +ile. $!"; # 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);
What am I missing, doing wrong? Thanks in advance for any/all help!
Brother Zo.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting from Oracle to become a text file
by tommyw (Hermit) on Oct 04, 2001 at 21:09 UTC | |
Re: Getting from Oracle to become a text file
by runrig (Abbot) on Oct 04, 2001 at 21:11 UTC | |
Re: Getting from Oracle to become a text file
by Rhose (Priest) on Oct 04, 2001 at 21:14 UTC | |
Non-Perl way...
by Rhose (Priest) on Oct 04, 2001 at 21:19 UTC | |
Re: Getting from Oracle to become a text file
by Zo (Scribe) on Oct 04, 2001 at 21:19 UTC | |
Re: Getting from Oracle to become a text file
by jbert (Priest) on Oct 05, 2001 at 19:07 UTC |
Back to
Seekers of Perl Wisdom