develooper Front page | perl.beginners | Postings from May 2002

RE: select from oracle and write to file

Thread Previous | Thread Next
DeBaets, Kirk
May 1, 2002 07:07
RE: select from oracle and write to file
Message ID:
Between execute and finish add fetchrow_array() to get the result set,
and then do with the rows what you wish.  E.g.,

my @row;
while ( @row = $sth->fetchrow_array() ){
  print "Row:  @row\n";

-----Original Message-----
From: garrett esperum []
Sent: Tuesday, April 30, 2002 6:20 PM
Subject: select from oracle and write to file

Hello all,

Solaris, Oracle 8.1.6, Perl 5

How do I write my selected row from Oracle out to a new file? Below is
I have so far. I can select the row, but I don't know how to write it to
new file:

#!/usr/local/bin/perl -w
# REMEMBER! Set the environment variable: ORACLE_HOME=/path-to-oracle
running this script.

use strict;
use DBI;

my $dbh = DBI->connect( 'dbi:Oracle:db',
                        RaiseError => 1,
                        AutoCommit => 0
                        ) || die "Database connection not made: 
my $sql = qq{ SELECT oid FROM bv_ep_project };
my $sth = $dbh->prepare ( $sql );

Thank you for your help!!!


Get your FREE download of MSN Explorer at

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About