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 <newbie01.p...@gmail.com> 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/