tags:

views:

526

answers:

2

My program works already, I have Perl (GUI Window) where I can input data, data passed to the webpage (using to Tomcat server, JSP) and then saved it to oracle database. What I want is to make search parameter (webapp) that retrieve/extract data from the Oracle database using Perl CGI. Is it possible? Or any suggestions to solve my program? Thanks!:-)

+2  A: 

Any specific reason for the mix in technologies? Why not use a servlet/JSP?

If you must use Perl, then you need to choose what web-server will run your Perl script.

Normally, this would be Apache using mod_perl.

But if you only intend to use this for a few admin scripts, then you can run Perl from tomcat as outlined here.

Once you have managed to get a simple perl script running, then I would look into using DBI/DBD::Oracle to access your database?

Hope this helps...

toolkit
What if there is no DBI Installed? Using this is not recommended in the line because it can caused the production slower since we are directly to the controller(e.g. time, hang-up). Thanks for the answer and references you have given. It gaves me an idea on how to work with it:-).
Shiel
+5  A: 

Yes u can by using DBI and DBD::Oracle modules.

However there are some gotchas with Oracle. I remember a few fun and games with Oracle 8 so these may no longer be applicable but it did require setting ENV variables like ORACLE_HOME, ORACLE_BASE & ORACLE_SID in some cases.

The DBD::Oracle doc does go into this and also mentions another ENV variable TWO_TASK. So getting it to work may depend on....

  • what version of Oracle u have running
  • whether u have listener up (which I think u do need for network access like CGI?)
  • what version SQL*Net your using.

Seems daunting but all you will probably need is to add these ENV variables in the webserver (iPlanet was what I was using at that time). Alternatively from the DBD::Oracle doc it gives...

BEGIN {
  $ENV{ORACLE_HOME} = '/home/oracle/product/10.x.x';
  $ENV{TWO_TASK}    = 'DB';
}
$dbh = DBI->connect('dbi:Oracle:','scott', 'tiger');
#  - or -
$dbh = DBI->connect('dbi:Oracle:','scott/tiger');

/I3az/

PS. The above assumes you are running CGI script on same server as Oracle! If not then those ENV variables are superfluous and u can just do this (pulled from old script of mine!)...

my $db = DBI->connect("dbi:Oracle:host=$host;sid=$database", $user, $pass, 
  { RaiseError => 0, PrintError => 0 } )
  or croak( "Unable to connect to DB - $DBI::errstr" );

However I do recall having to tweak something like TNLISTENER.CONF on the Oracle server (this was some years ago so memory fails me a bit!) and I'm pretty sure u need to download some client Oracle library (which u can get from their site).

draegtun
I configure my program using Tomcat version 4.1.31, Netbeans 6.1, Oracle 10g with SQL*Plus 10.2.0.1. Actually I have no DBI installed in my system so I prefer using that setup. I think I must try DBI? Thanks!:-) It gaves a lot of ideas.
Shiel
draegtun
If u're using Windows then have a look at this doc... http://search.cpan.org/src/PYTHIAN/DBD-Oracle-1.22/README.win32.txt
draegtun
draegtun