if ( $pid = fork() ) {
##########
# Sets up the Unix and Oracle variables for the system
##########
$ENV{ORACLE_HOME} = '/home/oracldwh/app/oracle/product/7.3.2';
$ENV{LD_LIBRARY_PATH} = '/home/oracldwh/app/oracle/product/7.3.2/lib';
# Database connection variables
my $database = "**********";
my $username = "**********";
my $password = "**********";
my $html;
##########
# Create initial portion of page with title and heading
##########
$html .= header( -Refresh=> '0'; 'manager_selection_fork.cgi');
$html .= $query->start_html(-'title'=>'Asset Insight Manager Resources',
-BGCOLOR=>'#00CCFF');
##########
# Created the form portion
##########
$html .= "
";
$html .= $query->startform({-method=>'post', -action=>'http://www3.syr.lmco.com/cgi-bin/asset/employee_list.cgi', -target=>'bottom'});
##########
# Connects to the database and runs the specified query
##########
my $dbh = DBI->connect($database, $username, $password, 'Oracle')
or die "can't connect to $database: $DBI::errstr";
my $sth = $dbh->prepare( q{
SELECT DISTINCT e1.emp_badge, e1.emp_name_last, e1.emp_name_first, e1.emp_job_ttl
FROM emp e1, emp e2
WHERE e1.emp_ssn = e2.mgr_ssn
AND e1.emp_badge is not NULL
ORDER by e1.emp_name_last
}) or die "Can't prepare statement: $DBI::errstr";
my $rc = $sth->execute()
or die "Can't execute statement: $DBI::errstr";
my @the_values;
my %labels;
##########
# Concatnates each returned row and pushes them into an array
##########
while (my ($emp_badge, $emp_name_last, $emp_name_first, $emp_job_ttl) = $sth->fetchrow()) {
$labels{"$emp_badge"} = join(' -- ', $emp_name_last, $emp_name_first, $emp_job_ttl);
push(@the_values,$emp_badge);
}
##########
# Creates the dropdown box with the apropriate names and associations
##########
$html .= $query->popup_menu(-name=>'mgr_badge',-'values'=>\@the_values,-labels=>\%labels);
$html .= $query->submit(-value=>'Submit Selection');
$html .= "
";
$html .= end_html;
##########
# Prints out the entire HTML Page as it was created above
##########
print $html;
# check for issue we may have had durring this little excursion
warn $DBI::errstr if $DBI::err;
##########
# This Ends the statement handle and closes the connection to the database
##########
$sth->finish;
$dbh->disconnect;
}
##########
# The Child portion of the Fork
##########
elsif ( defined( $pid ) ) {
my $html2;
$html2 .= header;
$html2 .= $query->start_html(-'title'=>'Loading',
-BGCOLOR=>'#00CCFF');
$html2 .= "