Hello,

When I run a script from shell using DBI and I have LIBPATH set to something other than when DBI was compiled, I get a install_driver(oracle) error and the script dies.

$dbh = DBI->connect(dbi:Oracle:etc.....)

unsetting LIBPATH always works. The problem is I want to trap this error so the script doesn't die if someone executes it with the wrong LIBPATH. The only way I have found to do this is the expensive operation of calling

my @drivers = DBI->installed_versions;

and then check to see if Oracle is there before I DBI->connect.

I have tried all methods of RaiseError, PrintError and eval around the DBI->connect, but all still die with the install_driver(oracle) error.

Additionally, since the linkers cache the LIBPATH value before the script even executes (from what i understand), i can't unsetLIBPATH in a BEGIN block either.

Does anyone have a suggestion as to how I can deal with this other than using DBI->installed_versions ?

Editted by BazB: fixed formatting/code tags.


In reply to DBI problems. by dbaad

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.