Re: Script to test connecting to Oracle DBs

Leo Susanto <[email protected]>
Newsgroups gmane.comp.lang.perl.beginners,gmane.comp.lang.perl.modules.dbi.general
Message-ID <CADpbghOH5qVgMXp6UEJQW_+KFNWnYZ-bTb6gE0ys6Prv3dkKUg@mail.gmail.com>
use strict;
use DBI;
use DBD::Oracle qw(:ora_types);

my $user   = '';
my $passwd = '';
my $tnsName = '';

$ENV{'ORACLE_HOME'} = 'C:\oracle\product\10.2.0\client_1';
my $dbh = DBI->connect("dbi:Oracle:$tnsName", $user, $passwd);
my $SQL = qq{ SELECT XXX};

my $sth0 = $dbh->prepare($SQL);
print "SQL is prepared;\n";
$sth0->execute();
print "SQL is executed;\n";
$sth0->finish();


On Fri, Jul 27, 2012 at 6:45 PM, newbie01 perl <[email protected]> wrote:
> Hi all,
>
> I am looking for a Perl script or something similar that I can use to test
> connection from a client PC to several databases on a server.
>
> Does anyone know of any such script lying around somewhere :(-
>
> Currently, am testing connection from a client PC to an Oracle DB using
> Oracle's sqlplus. All is well and good until I have to test connection to
> multiple databases on the server.
>
> So I am hoping to use a Perl script that I can use which will parse some
> sort of config file that contains hostname.tns_alias combination and then
> test connection to the Oracle DB and run a simple SQL like SELECT COUNT(1)
> from USER_TABLES, if I get an error, that means there is an issue
> connection to that database, otherwise all is good.
>
> At the moment, easiest I can think of using Perl's system command to run
> sqlplus. Or is it better to look at using DBI? Would be very much
> appreciated if someone can provide me a simple DBI script to start with if
> that is the best approach to use.
>
> Any suggestion/advice much appreciated. Thanks in advance.

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.