Re: Access Oracle from CGI? How?

From: Thomas J Kyte <tkyte_at_us.oracle.com>
Date: 1995/10/13
Message-ID: <45lqdm$ja_at_inet-nntp-gw-1.us.oracle.com>#1/1


Eric_Karabin_at_msn.com (Eric Karabin) wrote:

>I can connect to Oracle in a simple Pro*C program on my SGI INDY, but
>when I try to do it in as a CGI program, I get the error:
>ORA-12545: Unable to open message file (SQL-02113).
 

>Why does it fail as a CGI program?
>Even if I change my Netscape server user from Nobody to my own name,
>it gives the same error.
 

>Eric

The environment is not setup when you run a CGI program. When you run the cgi application, the environment is set up explictly by the httpd and only contains 'web' stuff. You need to run your c program from a sh script or something to setup the oracle environment. Below is a small sh script I use to test environments. You need to set oracle_home, oracle_sid, and path and perhaps others depending on your config (ie: if the database is on another machine you may need to set tns_admin or two_task or some other environment variable). Place the following sh script in your cgi-bin area and play with the environment until you see the correct results come back. Then, replace the call to sql*plus with a call to your application.

#!/bin/sh

UN_PW=scott/tiger

ORACLE_HOME=/usr/oracle;export ORACLE_HOME ORACLE_SID=oracle;export ORACLE_SID
PATH=$PATH:/usr/oracle/bin;export PATH

sqlplus -s $UN_PW << "EOF"
prompt Content-type: text/html
prompt

set linesize 100

prompt <HTML>
prompt <body>
prompt	<TITLE>Testing Connection</TITLE>

prompt	<H1> Select * From Emp </H1>

prompt <pre>
select * from emp;
prompt </pre>

prompt	</body>
prompt	</HTML>

EOF Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government Received on Fri Oct 13 1995 - 00:00:00 CET

Original text of this message