D
dn.perl
I have two tns-connection-strings with me. Only one of them is active
at any given time.
Same schema, usernames, passwords apply to both.
I would like to try to connect via string-1, and if it fails connect
via string-2. But the program just aborts when a dbi->connect call
fails. No second chance allowed.
Sample code:
my $dbh ;
$dbh = DBI->connect("dbi:Oracle:tns-string1 etc etc etc");
if (!$dbh ) {
$dbh = DBI->connect("dbi:Oracle:tns-string2 etc etc etc");
}
## die if both attempts fail
die $dbh->errstr if !$dbh ; ## I can live without this statement
return $dbh ;
I suspect there must be some internal variable set by default to make
a program exit if DBI->connect fails.
How can I make the above code work?
TIA.
at any given time.
Same schema, usernames, passwords apply to both.
I would like to try to connect via string-1, and if it fails connect
via string-2. But the program just aborts when a dbi->connect call
fails. No second chance allowed.
Sample code:
my $dbh ;
$dbh = DBI->connect("dbi:Oracle:tns-string1 etc etc etc");
if (!$dbh ) {
$dbh = DBI->connect("dbi:Oracle:tns-string2 etc etc etc");
}
## die if both attempts fail
die $dbh->errstr if !$dbh ; ## I can live without this statement
return $dbh ;
I suspect there must be some internal variable set by default to make
a program exit if DBI->connect fails.
How can I make the above code work?
TIA.