Connect ORACLE to WWW through CGI-Perl-Script

Connect ORACLE to WWW through CGI-Perl-Script

Post by Ingo Rut » Wed, 18 Dec 1996 04:00:00



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.

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Gary Eber » Wed, 18 Dec 1996 04:00:00



> 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;

Quote:}

--
Gary Ebert
Mobile Datacom Corporation
22300 Comsat Drive, Clarksburg, MD 20871
Phone: 301-428-2115 Fax: 301-428-1004

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Patrick Ril » Wed, 18 Dec 1996 04:00:00



Quote:>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've been doing some of this lately.  Put your SQL in a file
and run by:



to a file, then open in perl.  Remember to put a "spool off" after
the select-statement.

Have fun,
Patrick

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Theodore Hop » Wed, 18 Dec 1996 04:00:00




> >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.
> I've been doing some of this lately.  Put your SQL in a file
> and run by:



I suggest you check out OraPerl at

  http://src.doc.ic.ac.uk/packages/perl/db/perl4/oraperl

-T.H.

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Charlie W » Wed, 18 Dec 1996 04:00:00



> The CGI-Perl-script should do this:
> 1. Connect DB (here: SQL-PLUS)
> 2. SELECT * FROM ...
> 3. DISCONNECT DB

i mainly use sybase but it should be no difference. what i usually
do is write a shell script to do the database inquiries and then
pass the result to perl.

e.g.

$cmd = `/bin/ksh sql.sh arg1 arg2`;
print `$cmd`;

and the in sql.sh you can have

#!/bin/ksh
/sybase/bin/isql -Uuser -Ppasswd << END_SQL
your sql goes here
END_SQL
#end of script

hope that helps.

--
Charlie Wu
Web Applications Developer/Consultant
AT&T, Atlanta, Georgia

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Paul Barton-Dav » Thu, 19 Dec 1996 04:00:00


:  [ wants to connect to Oracle from Perl ]

: I suggest you check out OraPerl at

:   http://src.doc.ic.ac.uk/packages/perl/db/perl4/oraperl

I'd suggest you upgrade to Perl 5.0, and use the DB interface.  Its
the only sane way to use Perl and Oracle together if you actually
expect a heavy load on your web server. To be honest, when I expect a
heavy load on the web server, I'd forget about coupling Oracle and
Perl together. Although the DB interface is implemented pretty well,
there are several important relational database concepts that are hard
to map into Perl's world (like NULL columns, for example).  If you're
dealing with datasets where every column is text or just a number and
is always filled, then Perl works OK. oraperl is not very speedy,
however.

As a sidenote, does it amaze anyone else that Oracle has completely
failed to come up with a decent C interface to their server code ? OCI
is functional, but hardly convenient. Its not very difficult to write
a sscanf() like interface - I've done it twice, and I know at least
one other person who has done the same. Given that internal Oracle
developers do the same thing for themselves, how come Oracle has been
so lame with their exported interface ?

And as a second sidenote, can I also comment on how unbelievable it is
to me that Oracle chose PL/SQL as the language their web server uses
for "extensions" ? This ADA/SQL monstrosity is admitted by the people
who actually implemented it to be incredibly slow compared to native
code, and SQL itself is so far from being even close to the kind of
language I would want to use for Web work ... how much more useful
their server would have been if they had added a reaonable API, and
let you do run-time dynamic linking of object code into their server,
like Netscape and Apache do. That allows you to write in the language
of your choice, rather than a lame attempt at proceduralizing SQL.

Oh well, thankfully its not hard to extend Apache to provide the
same kind of simple access to an Oracle database that OWS does.

--p

--
hybrid rather than pure; compromising rather than clean;    | Militant Agnostic
distorted rather than straightforward; ambiguous rather than| I Don't Know
articulated; both-and rather than either-or; the difficult  |   and You Don't
unity of inclusion rather than the easy unity of exclusion. |   Know Either

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Ferenc Math » Fri, 20 Dec 1996 04:00:00


Ingo,
if you have Oracle's Webserver already installed then do not use Perl, use
stored procedures to create dynamic SQL and HTMLpages.
Regards,
Ferenc




> > 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

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Marc Portie » Fri, 20 Dec 1996 04:00:00


If I'm not mistaking the Oracle Web Agent (a full featured cgi that
launches stored procedures for you) is available for free for all oracle
databases later than 7.0. only the websystem 2 requires new licenses...

check it out with your vendor...
the main goal of the owa was to recycle investment in training staff to
use pl/sql... with limited web knowledge you can link your oracle to the
web...

-marc=

--
Marc Portier                               e-COM Interactive Expertise
Software Engineer                         Innovatie & Incubatiecentrum

http://www.ecom.be/cvmpo.htm                         B-9052 Zwijnaarde
tel:+32-9-2415640                                    tel:+32-9-2415600
                                                     fax:+32-9-2451814

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Chris Eastla » Wed, 25 Dec 1996 04:00:00



>As a sidenote, does it amaze anyone else that Oracle has completely
>failed to come up with a decent C interface to their server code ? OCI
>is functional, but hardly convenient. Its not very difficult to write

I find OCI very convenient, personally. Try writing code a bit
in Sybase Open Client or ODBC and you'll learn to appreciate it more.
 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Ole Molle » Tue, 31 Dec 1996 04:00:00


Quote:> >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

Yet another way to do this is to choose your weapons right. I use one of
the following approaches:

1. Make a shell-script like:

sqlplus -s usr/passwd << EOF
select * from ...
EOF

This can off course be further complicated by introducing PL/SQL. If it
turns out to be too complex I use Pro*C to make a small program, which i
call from the CGI-shell script.

Regards

Ole Moller

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Jacqui Care » Fri, 03 Jan 1997 04:00:00









>> >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.

>> I've been doing some of this lately.  Put your SQL in a file
>> and run by:


>I suggest you check out OraPerl at

>  http://src.doc.ic.ac.uk/packages/perl/db/perl4/oraperl

this is obsolete :-)
hermitica.com is the place for perl5 Oraperl.pm
but go through the CPAN archives and
try looking for

Oraperl        Rmpf  Oraperl emulation interface for DBD::Oracle  DBIML !

which is an interface to the DBD::Oracle.pm perl5 package.

perl4 is NOT recommended.

Also, look at the perl5 CGI modules including the CGI::MiniServer
and Apache:: modules if you need to do commit/rollback over multiple
CGI transactions.

Quote:>-T.H.

I have worked with the Oracle web server (owa) and it is still
as buggy as hell..., but is probably the way to go if you
are talking intranet applications.

p.s. I understand (but may be wrong) that Oracle WS2 licence
does not permit use of webserver2 connected to the internet.

p.p.s
if you do use perl remeber to set you enviroment up.

i.e.

$ENV{"ORACLE_HOME"} = "/home/oracle/home";
$ENV{"ORACLE_SID"} = "xxxxx";
$ENV{"TWO_TASK"} = "sssss.yyyy.co.uk";
...

and remeber to add $ORACLE_HOME/bin to your path if you intend
to run any oracle binaries from system `` or open("sqlplus |")...

If you are using Apache, you  can configure ORACLE_HOME etc
into the env using SetEnv and PassEnv - this does not work
with the mod_perlfast though...

All the best,
        Jacqui Caren
--

Commercial perl resources - support,training,products etc

AD: Need flexible, high quality reporting? - www.perl.co.uk/ig/dp.html

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by SREE » Mon, 06 Jan 1997 04:00:00


I think I understand your question correctly !
What is the problem with Pro*C /PL/SQL or OCI ?
I guess it is the best interface to RDBMS kernel compared to any other
products like SYBASE / INFORMIX .

Did you ever try using the Oracle Web Server 2x ? You dont want to do lot
of C code in Oracle any way. I bet there is always a cute way of writing
programs using PL/SQL oracle web agent. If you are going to use your own
PEARL scripts etc, you may have the headache of maintaining connections to
the DB etc.

Good Luck
Sree

 
 
 

Connect ORACLE to WWW through CGI-Perl-Script

Post by Alan Burliso » Tue, 07 Jan 1997 04:00:00



> If you are going to use your own
> PEARL scripts etc, you may have the headache of maintaining
> connections to the DB etc.

Please note, it is Perl, not PEARL (Blame Larry Wall, not me ;-)

It is very easy to get data from Oracle using Tim Bunce's Most Excellent
interface, for example:

my $drh = DBI->install_driver('Oracle');
my $dbh = $drh->connect('SID1', '/') || die($DBI::errstr);
my $csr = $dbh->prepare("select item, cost from inventory order by
item");
$csr->execute();
my ($item, $cost);
while (($item, $cost) = $csr->fetchrow())
   {
   print("$item costs $cost<BR>\n");
   }
$csr->finish();
$dbh->disconnect();

This in conjunction with the Perl CGI library makes it very easy to
write scripts
that interface to Oracle and to the rest of the world.  Try sending
email from
Oracle's WOW interface, for example...

--
Alan Burlison

My opinions may be incorrect, but they are my own.

 
 
 

1. Connect ORACLE to WWW through CGI-Perl-Script

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.

2. Help! Help! Help?

3. Connect ORACLE to WWW through Pro*C-CGI scripts (was:CGI-Perl)

4. Primary key and references

5. 18416-PA-HARRISBURG-Java-C-C++-CGI Scripting-DB2-ORACLE-Perl-HTTP Server Program

6. Avis de recherche

7. error compiling 7.3.2 on solaris 8- library conflict

8. Oracle Web and Perl CGI scripts

9. FmPro Migrator 1.46EE migrates FileMaker to Oracle - and generates Perl CGI scripts

10. 18416-PA-HARRISBURG-Java-C-C++-CGI Scripting-DB2-ORACLE-Perl-HTTP Server Program

11. Building WWW Databases using perl/CGI

12. SQL Server 6.5 & Perl cgi scripts