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).

#!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.

In reply to Getting from Oracle to become a text file by Zo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.