Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: CGI call to an Oracle Server
Stephen Wang <wangste_at_flux.cpmc.columbia.edu> wrote:
: Thanks for the information. I guess that I did not ask my question in a
: correct way. I basically need to some scripts in C or perl that does the
: database connection and getting results. I know if I search I can find plenty of
: examples but I thought asking the question at this newsgroup might give me a
: quick answer.
I can help with some PERL examples. I am still trying to get the C precompiler to work... The script below is written to be run from Apache's mod_perl interface. What mod_perl does is allow the script's variables to persist across CGI requests. It also keeps the modules in memory. When doing Oracle stuff from these CGI scripts, I consider the use of mod_perl mandatory.
#!/usr/bin/perl -w
use CGI;
use DBI;
################ Initialization Stuff ###############
unless ($init_done) {
# Create CGI object
$cgi = new CGI;
}
# Print standard header
print $cgi->header;
unless ($init_done) {
$ENV{ORACLE_HOME} = "/mnt/oracle/OraHome";
# Create database connection...
unless ( $dbh = DBI->connect('DBI:Oracle:host=blah.com;sid=test', 'test', 'test', { RaiseError => 1, AutoCommit => 1 }) ) {
print "Could not connect to database.\n"; exit;
############## End Initialization Stuff #############
print "Database results:<P>\n";
$statement = "select * from users where u_name = 'Kirk'"; $sth = $dbh->prepare($statement); $sth->execute();
print "@row<P>\n";
}
exit;
--
Kirk Bauer -- CmpE, Georgia Tech -- kirk_at_kaybee.org -- Avid Linux User
GT Sport Parachuting Club! http://cyberbuzz.gatech.edu/skydive Opinions expressed are my own, but they should be everybody's. Received on Fri Feb 18 2000 - 16:24:48 CST