Re: A common perl script for different database platforms
- From: alexander@xxxxxxxx (Alexander Foken)
- Date: Sun, 26 Feb 2006 07:15:55 +0100
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/
.
- References:
- A common perl script for different database platforms
- From: Hetal Soni
- Re: A common perl script for different database platforms
- From: Tyler MacDonald
- A common perl script for different database platforms
- Prev by Date: Re: A common perl script for different database platforms
- Next by Date: Zip Codes, Long/Lat and LAMP?
- Previous by thread: Re: A common perl script for different database platforms
- Next by thread: Zip Codes, Long/Lat and LAMP?
- Index(es):
Relevant Pages
|