You still need this line: use DBI;
Do you have that still? -Will -----Original Message----- From: Hetal Soni [mailto:[EMAIL PROTECTED] Sent: Monday 27 February 2006 17:27 To: Alexander Foken; [email protected] Subject: RE: A common perl script for different database platforms Thanks for your input guys. I removed both "use:DBD::Oralce" and "use"DBD:DB2" lines and now getting following error: Can't locate object method "connect" via package "DBI" (perhaps you forgot to lo ad "DBI"?) at tmp1.plx line 58. Any suggestion? Thanks again, Hetal. -----Original Message----- From: Alexander Foken [mailto:[EMAIL PROTECTED] Sent: Sunday, February 26, 2006 1:16 AM To: [email protected] Cc: Hetal Soni Subject: 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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] http://www.foken.de/alexander/ NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies and attachments of the original message. - - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
