Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Connect ORACLE to WWW through CGI-Perl-Script

Re: Connect ORACLE to WWW through CGI-Perl-Script

From: Gary Ebert <gary_at_www.rdss.com>
Date: 1996/12/17
Message-ID: <32B706CD.5CF4@www.rdss.com>#1/1

Ingo Ruth wrote:
>
> Hallo!
> I'm trying to connect an ORACLE-DB to the WWW throught CGI.
> Because I want to learn more about it, I took Perl to write a
> script - but I don't also want to use oraperl.
> The database is running on a Solaris2.4 platform, and there is an
> ORACLE-Web-Server 1.0 for the WWW-requests.
>
> The CGI-Perl-script should do this:
> 1. Connect DB (here: SQL-PLUS)
> 2. SELECT * FROM ...
> 3. DISCONNECT DB
>
> Therefore I wrote this:
> [...]
> print `sqlplus user/passw`;
> print `select * from obj;`;
> print `exit`;
> [...]
> As the result in the WebBrowser I could first see something
> like "connected...", then there was an empty row and at last
> somthing like "disconnected..." - but no result of the request.
> I think the problem is about standardin /-out: when the DB is
> connected, I don't know where <STDIN> and <STDOUT> are lying on.
>
> Next I tried to get the result of the request into a file
> with the line
> print `spool /export/home/www/ergebn.data`;
> before the select-statement. This should send the answerstream
> into the file ergebn.data, but I found no file in that path.
>
> At last I put a pipe a) before and b) after the select-statement -
> nothing new happened.
>
> So what could I do? Is there anybody who knows how to handle
> standardin/-out in this case?
>
> Ingo Ruth.

I don't know if this is exactly what you are looking for but here goes.

The following subroutine calls sqlplus and loads the info obtained into a hash.
Again this isn't exactly what you're looking for but I'm hoping that it will point you (or
others) in the right direction

sub mysubroutine
{

    open(SQLPLUS, "/usr/oracle/bin/sqlplus username/password <<! SET SQLPROMPT \" \"
SET HEADING OFF
select col1, col2
from table1
order by col2;
quit;
! |")

        || die "cannot open sqlplus process: $!\n";

    while (<SQLPLUS>)
    {

	if ($_ !~ /\./ &&
	    ($_ ne "\n"))
	{
	    ($var1, $var2) = /^(\S+)\s+(.+)$/;
	    $hash{$var2} = $var1;
	}

    }
    close (<SQLPLUS>);
    return %hash;
}
-- 
Gary Ebert
Mobile Datacom Corporation
22300 Comsat Drive, Clarksburg, MD 20871
Phone: 301-428-2115 Fax: 301-428-1004
Received on Tue Dec 17 1996 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US