Re: Using Perl to connect with Oracle Database
From: John D Groenveld <groenvel_at_cse.psu.edu>
Date: 6 May 1999 12:39:27 -0400
Message-ID: <7gsgjv$9l0$1_at_tholian.cse.psu.edu>
}
print "\n";
}
$sth->finish
Date: 6 May 1999 12:39:27 -0400
Message-ID: <7gsgjv$9l0$1_at_tholian.cse.psu.edu>
Install DBI and DBD::Oracle modules and read the docs.
John
groenveld_at_acm.org
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Oracle:", "scott", "tiger")
or die "$DBI::err: $DBI::errstr\n";
my $sth = $dbh->prepare("SELECT * FROM emp")
or die "$DBI::err: $DBI::errstr\n";
$sth->execute()
or die "$DBI::err: $DBI::errstr\n";
my $row_ref;
while ($row_ref = $sth->fetchrow_hashref) {
die "$DBI::err: $DBI::errstr\n" if $DBI::err; foreach (keys %$row_ref) {
print $row_ref->{$_} if defined $row_ref->{$_}; print "\t";
}
print "\n";
}
$sth->finish
or die "$DBI::err: $DBI::errstr\n";
$dbh->disconnect
or die "$DBI::err: $DBI::errstr\n"; Received on Thu May 06 1999 - 18:39:27 CEST