#!/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"; # get parameter from CGI call my $name = param("name"); # the three arguments for the DB connection call my $username = "swang"; my $password = "B00999999"; my $dbName = "TRCH"; # creates a Database Handle (a reference) to the database that # we are connecting to; if the connection fails then the program # terminates my $dbh = DBI->connect("dbi:Oracle:$dbName", $username, $password) || die "ERROR: $DBI::errstr "; # creates a statement handle (a reference to a specific SQL statement) # that will access that database (given by $dbh); the statement handle # contains the specific query; any user input values should be repersented # by ?, which is later filled in my $sth = $dbh->prepare("insert into person values(?)"); # execute the query in the statement handler, subsituting the scalar $name # for the ? in the statement; the return value is the number of rows # changed my $rv = $sth->execute($name); # signal we are finished with the statement and it can be destoryed; $sth->finish; # disconnect from the database; $dbh->disconnect(); # print context type header print header(); # print the HTML print< CSCI 4173 Hello $name - the return code was $rv EOE ;