Re: Perl, Oracle, and a browser
Date: Sun, 16 Dec 2001 01:16:32 -0500
Message-ID: <3C1C3C40.7D6ABC2F_at_earthlink.net>
Yurasis Dragon wrote:
[snip]
> It seems to be when I try to connect to an Oracle database
> that I have the problem. So I ran the script at the command
> line as root and found that it did not run correctly until I defined
> ORACLE_HOME.
>
> So this leads me to suspect that Apache needs to know about
> ORACLE_HOME in order for my Perl script that accesses an Oracle
> database to work in a browser.
Close. The ORACLE_HOME environment variable needs to be set when the database driver for Oracle is loaded. There's two ways to do this: either have it set in the envrionment which starts up the perl program, or set it within the perl program sometime before you load the database driver. If your program is running as a CGI, then to have that variable set in the environment before perl starts, it would have to be done via the web server.
> So the question is where do I define ORACLE_HOME and how. Is
> it something like "SetEnv ORACLE_HOME /oracle/product/8.1.7"
> added in httpd.conf?
That's one way to do it.
> I think that I can do a similar thing in my Perl script directly ( I'm
> pretty new to Perl but do recall that I can set an environment
> variable in Perl ) but I don't want to have to do that to every Perl
> script, a more global solution is preferable and much more elegant.
If you put all your environment settings in a single perl file, perhaps called My_Ora_Config.pm, then you could simply add a line "use My_Ora_Config;" some point before the line which says "use DBI;"
Inside of My_Ora_Config.pm you would have a line like the following:
$ENV{ORACLE_HOME} = "/oracle/product/8.1.7"
And maybe some other environment settings.
Of course, you still would have to add the "use" line to every script which uses DBI, so maybe that's not so hot an idea. I would go with putting the line in httpd.conf
-- Klein bottle for rent - inquire within.Received on Sun Dec 16 2001 - 07:16:32 CET
