Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: OT: perl q
Lisa,
What gives you that idea? Seriously. Is there some piece of documentation that is telling you that? If so I would love to see it.
DBI is a database interface for Perl. DBD::Oracle is the module that allows DBI to talk to Oracle databases.
Sqlplus has nothing to do with this.
There's an example of connecting to Oracle with Perl at the end of this message.
Check out www.perl.com and search for DBI tutorials. Better yet, get 'Programming the Perl DBI'.
Jared
#!/usr/bin/perl
# template for DBI programs
use DBI;
use strict;
use Getopt::Long;
our %optctl = ();
Getopt::Long::GetOptions(
\%optctl, "database=s", "username=s", "password=s", "z","h","help");
our($db, $username, $password);
if ( ! defined($optctl{database}) ) {
Usage(); die "database required\n";
if ( ! defined($optctl{username}) ) {
Usage(); die "username required\n";
$username=$optctl{username};
$password = $optctl{password};
our $dbh = DBI->connect(
'dbi:Oracle:' . $db, $username, $password, { RaiseError => 1, AutoCommit => 0 } );
die "Connect to $db failed \n" unless $dbh;
our $MySql="select \* from dual";
our $sth = $dbh->prepare($MySql);
our $rv = $sth->execute || die "error with statement $MySql \n";
while( my $ary = $sth->fetchrow_arrayref ) {
print "\t\t$${ary[0]}\n";
}
$sth->finish;
$dbh->disconnect;
sub Usage {
print "\n"; print "usage: DBI_template.pl\n"; print " DBI_template.pl -database dv07 -username scott\n"; print "\n";
"Koivu, Lisa" <lisa.koivu_at_efair To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> field.com> cc: Sent by: Subject: OT: perl q root_at_fatcity.com 12/04/01 06:50 AM Please respond to ORACLE-L
Good morning everyone,
I apologize for the OT post.
I was looking at the DBI. It suddenly occurred to me that I can only connect to sql*plus with this. I'm not minimizing it's usefulness, but I am wondering if I can use a perl script to fire off the rman backup, scan the log for errors, mail the log, etc. everything I used to do in ksh.
Any examples of a "host" type command or something that may possibly meet my needs would be greatly appreciated and rewarded by a virtual monkey beer :)
Thank you
Lisa Koivu
Oracle Database Monkey.
Fairfield Resorts, Inc.
954-935-4117
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: Jared.Still_at_radisys.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Dec 04 2001 - 17:24:12 CST
![]() |
![]() |