Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have the following in my startup.pl

use Apache; BEGIN{$ENV{ORACLE_HOME}='/home/' use Apache::DBI(); use DBI(); use DBD::Oracle(); #httpd fails when I include this } use Apache::MyModule;

Httpd starts with no issues when I dont include DBD::Oracle and it silently fails when I include DBD::Oracle.I use this module to read BLOBs in my project.Please help

Edited: ~Mon Sep 16 19:30:15 2002 (GMT) by footpad: Added <code> and other HTML formatting tags, per Consideration.

Replies are listed 'Best First'.
Re: httpd fail to start when I include DBD::Oracle in the startup.pl
by perrin (Chancellor) on Sep 16, 2002 at 19:31 UTC
    Debug it. Does it work from a command-line script? Does it work when don't use it until after startup.pl? Is it looking for some environment variables that aren't being set? Try doing a require inside an eval block and checking the error message in $@. Usually things like this have to do with permissions, finding tnsnames.ora, and other little environment issues.
      Yes.the program ran from a command line and it also worked with "require".It doesnt work only if I put it in startup.pl . i am also not able to get an error message because it works everywhere.
        I think I see the problem. Your use statement is being executed before you set ORACLE_HOME. Try this (use Apache is not needed):
        BEGIN { $ENV{ORACLE_HOME}='/home/'; } use Apache::DBI(); use DBI(); use DBD::Oracle(); use Apache::MyModule;
Re: httpd fail to start when I include DBD::Oracle in the startup.pl
by jsprat (Curate) on Sep 16, 2002 at 23:17 UTC
    Does it work from the command line?

    First glance says you don't need to the line "use DBD::Oracle;", just DBI. You load the DBI later. For example:

    use strict; use DBI; my $dbname = 'ORCL'; #name of database # Here is where DBI loads DBD::Oracle my $dbh = DBI->connect( "dbi:Oracle:$dbname", 'scott', 'tiger', ) || die "Database connection not made: $DBI::e +rrstr"; $dbh->disconnect;

    HTH

    Update: You should probably search the mod_perl site for "persistent database connections"

    Clarified comment about "use DBI::Oracle;"

      The whole purpose of using DBD::Oracle is to read BLOB's.I need to set the ora_type to ORA_BLOB when I read it.Also I tried what perrin said, to set ORACLE_HOME before we use any modules. and it does'nt work.Please let me know if you have any other suggestion