Re: A common perl script for different database platforms



Right. And to explain why this does not work:

Perl handles "use" at compile time, not at runtime. "use WhatEver" is roughly equivalent to "BEGIN { require WhatEver; WhatEver->import() if WhatEver->can('import'); }", so you always use both DBD::Oracle and DBD::DB2, no matter what $opt_p contains.

If you want to load a module at runtime, use require.
If you want to load a DBI driver (DBD::*) at runtime, let DBI handle it.

Alexander

Tyler MacDonald wrote:

Hetal Soni <Hetal.Soni@xxxxxxxxx> wrote:


Below is code lines to use library for Oracle or DB2:

if ($opt_p eq "O") {
$DBType = "Oracle";
use DBD::Oracle;
};

if ($opt_p eq "D") {
$DBType = "DB2";
use DBD::DB2;
};

If I comment "use DBD::DB2;" line out and then compile it it works fine.



You don't have to "use" a DBD:: driver to connect to it; when you
call DBI's "connect" method, it will do that for you. Try removing both
"use" lines above and see if that solves it.

Cheers,
Tyler




--
Alexander Foken
mailto:alexander@xxxxxxxx http://www.foken.de/alexander/

.



Relevant Pages

  • Re: stumped on a macro
    ... > (Of course, for the real code, I should use gensyms, and I'll have a load ... > compile time to pass to make-array and for the dotimes loop. ... Load reg1 indirect addr-reg-x ...
    (comp.lang.lisp)
  • RE: A common perl script for different database platforms
    ... A common perl script for different database platforms ... If you want to load a DBI driver at runtime, ...
    (perl.dbi.users)
  • A File like app.config
    ... where the application will copy them to the bin/debug or bin/release at ... compile time. ... Also I would like the control previews to load these ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Compile speed affected by amount of machine ram?
    ... difference at compile time, nor at runtime unless you load a lot of data in ... memory. ... Florida Department Of Transportation ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Call a method of a .NET-DLL
    ... I want to load a .NET-DLL dynamically in a VB6 application. ... that I am not able to reference the DLL during compile time ... Therefore I need to load the DLL dynamically. ...
    (microsoft.public.vb.winapi)