Very simple cgi page to run sqlplus script

To create a very simple web page which displays the results of an sql query you can simply do the following:

Underneath your apache installation, create a file in the cgi-bin directory

In my case $APACHE_HOME/cgi-bin/test.html

The content of this file is just the following:

echo Content-type: text/html
# Required blank line
export ORACLE_SID=Your SID Here
. oraenv
sqlplus -s username/password@database @file_containing_sql_you_want_to_run.sql

Then all you need to do is create a file called file_containing_sql_you_want_to_run.sql (also in $APACHE_HOME/cgi-bin)

This file needs to contain the following:

set  markup html on -- the most important line
set heading off
set feedback off
select sysdate from dual; -- your sql here
exit; -- this is needed to get the script to exit or the page will just hang

And thats it - this produces a very simple page - this is useful for utilities and provding access to some data to other people without needing database logins etc


  1. Hi, its an excellent CGI page to run sqlplus script.Thanks for you support..