When using tnsnames.ora as proposed, just set the environment $TWO_TASK and be done with it.

$ echo $TWO_TASK dbo_foobar $ tnsping $TWO_TASK TNS Ping Utility for Linux: Version 12.1.0.1.0 - Production on 03-SEP- +2014 11:25:08 Copyright (c) 1997, 2013, Oracle. All rights reserved. Used parameter files: /pro/oracle/v12.1/network/admin/sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact ( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = ( H +OST = dbo)( PORT = 1521)( PROTOCOL = TCP))) ( CONNECT_DATA = ( SERVIC +E_NAME = foobar))) OK (150 msec) $ env DBI_TRACE=1 perl -MDBI -wE'DBI->connect ("dbi:Oracle:", split m{ +/} => $ENV{ORACLE_USERID})' DBI 1.631-ithread default trace level set to 0x0/1 (pid 9871 pi 1e +ba010) at DBI.pm line 288 via -e line 0 -> DBI->connect(dbi:Oracle:, USER, ****) -> DBI->install_driver(Oracle) for linux perl=5.020000 pid=9871 ru +id=203 euid=203 install_driver: DBD::Oracle version 1.74 loaded from /pro/lib/p +erl5/site_perl/5.20.0/x86_64-linux-thread-multi-ld/DBD/Oracle.pm <- STORE('ShowErrorStatement', 1)= ( 1 ) [1 items] at Oracle.pm li +ne 81 <- install_driver= DBI::dr=HASH(0x2045f30) <- connect('', 'USER', ...)= ( DBI::db=HASH(0x21ec3e8) ) [1 items] + at DBI.pm line 671 <- STORE('PrintError', 1)= ( 1 ) [1 items] at DBI.pm line 723 <- STORE('AutoCommit', 1)= ( 1 ) [1 items] at DBI.pm line 723 <- STORE('Username', 'USER')= ( 1 ) [1 items] at DBI.pm line 726 <- connected('dbi:Oracle:', 'USER', ...)= ( undef ) [1 items] at D +BI.pm line 733 <- connect= DBI::db=HASH(0x21ec3e8) <- STORE('dbi_connect_closure', CODE(0x21ebde8))= ( 1 ) [1 items] +at DBI.pm line 742 <- DESTROY(DBI::db=HASH(0x21ec310))= ( undef ) [1 items] at -e lin +e 1 <- disconnect_all= ( ) [0 items] (not implemented) at DBI.pm line +750 ! <- DESTROY(DBI::dr=HASH(0x2045f30))= ( undef ) [1 items] during gl +obal destruction

Enjoy, Have FUN! H.Merijn

In reply to Re: Oracle Database Connection by Tux
in thread Oracle Database Connection by MJohnson90

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.