Please enlighten me! Why does the first DBI->Connect work and does the second DBI->Connect throw an ORA-12154?
#!/usr/bin/perl
use strict;
use DBI;
print "DB connectivity test\n";
my $user='system';
my $password='manager';
my $DSN='dbi:Oracle://127.0.0.1:1521/db.company.local';
my $dbh = DBI->connect($DSN, $user, $password,
{ RaiseError => 1, AutoCommit => 0 });
print "This works\n";
my $DSN='dbi:Oracle:host=127.0.0.1:sid=db.company.local:port=1521';
my $dbh = DBI->connect($DSN, $user, $password,
{ RaiseError => 1, AutoCommit => 0 });
print "This doesn't\n";
Running the code yields the following result:
DB connectivity test
This works
DBI connect('host=127.0.0.1:sid=ps.kadaster.local:port=1521','system',
+...) failed: ORA-12154: TNS:could not resolve the connect identifier
+specified (DBD ERROR:
OCIServerAttach) at conn_test.pl line 16.