On Tue, Mar 02, 2004 at 03:25:28PM -0800, Aaron D. wrote:
> 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.
DBI->available_drivers is *much* cheaper.
> I have tried all methods of RaiseError, PrintError and
> eval around the DBI->connect, but all still die with
> the install_driver(oracle) error.
The DBI docs say:
: Driver installation either returns a valid driver
: handle, or it I<dies> with an error message that includes the string
: "C<install_driver>" and the underlying problem.
Using eval { ... } should work.
> 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.
Right.
> Does anyone have a suggestion as to how I can deal
> with this other than using DBI->installed_versions ?
Use available_drivers().
Tim.