Hi Monks,

I am trying to replicate the sqlplus '/as sysdba' connection using DBI and DBD::Oracle by following the guidelines from http://search.cpan.org/~pythian/DBD-Oracle-1.23/Oracle.pm#Connect_Attributes.

My tnsnames.ora is like this:

#Generated tnsnames.ora by gen_tnsnames.sh script #Localnode service connectivity ABCD12.COMPANYDOMAIN.COM = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = testserver24.companydomain.co +m )(PORT = 30710)) ) (CONNECT_DATA = (INSTANCE_NAME = ABCD12) (SERVICE_NAME = ABCD12.COMPANYDOMAIN.COM) ) )
and I have no problem connecting with the usual sqlplus '/as sysdba'.

I am doing the following in my script:

use DBI; use DBD::Oracle qw(:ora_session_modes); my $dsn = "dbi:Oracle:"; #$ENV{ORACLE_SID} = "ABCD12"; $ENV{ORACLE_SID} = "ABCD12.COMPANYDOMAIN.COM"; delete $ENV{TWO_TASK}; my $dbh = DBI->connect($dsn, "", "", { ora_session_mode => ORA_SYSDBA +});
and getting the error:
DBI connect('','',...) failed: ORA-12545: Connect failed because targe +t host or object does not exist (DBD ERROR: OCIServerAttach)

Specifying ORACLE_SID with/without the domain name doesn't change the error message. I have checked that $TNS_ADMIN is defined and the host name is present in /etc/hosts.

What am I doing wrong here?

Thanks, Ani


In reply to Connecting 'as sysdba' using DBD::Oracle by laminee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.