#!/usr/bin/perl -w use DBI; # database access module use strict; # enforce declaring of variable names use CGI qw/:standard/; # use CGI modules # set oracle environment $ENV{'ORACLE_HOME'}="/opt/oracle/9.0.1"; # display HTML header (Content-Type: text/html) print header(); # print some HTML print < EOE ; # connect to the database my $username = "swang"; my $password = "B00999999"; my $dbName = "TRCH"; my $dbh = DBI->connect("dbi:Oracle:$dbName", $username, $password) || die "ERROR: $DBI::errstr "; # prepares a statement, executes it my $sth = $dbh->prepare("select * from person"); $sth->execute(); # for each row of results, we print it on a new line my @row; while ( @row = $sth->fetchrow_array ) { print "name->$row[0]
\n"; } # finish statement $sth->finish; # disconnect $dbh->disconnect(); # print the HTML print< EOE ;