#!/usr/bin/perl use DBI; use CGI::Carp qw(fatalsToBrowser); use CGI; use CGI qw(:standard);; my ($sid) = "sohocat"; my ($user) = "soho"; my ($pass) = ""; $ENV{'ORACLE_HOME'} ="/dbsw/app/oracle/product/8.1.7"; my ($start_date, $end_date); #($start_date, $end_date, $selection, $limit) = verify_input(); ### Pick form input $startyear=param("startyear"); $startmonth=param("startmonth"); $startday=param("startday"); $starthour=param("starthour"); $startminute=param("startminute"); $endyear=param("endyear"); $endmonth=param("endmonth"); $endday=param("endday"); $endhour=param("endhour"); $endminute=param("endminute"); ### Create Oracle-friendly variables ### SOHO date variables are in the format: DD-MON-YYYY HH:MM:SS ### Convert search form month to a three-letter abbreviation %months = ("1" => "JAN", "2" => "FEB", "3" => "MAR", "4" => "APR", "5" => "MAY", "6" => "JUN", "7" => "JUL", "8" => "AUG", "9" => "SEP", "10" => "OCT", "11" => "NOV", "12" => "DEC"); $s_month=$months{$startmonth}; $e_month=$months{$endmonth}; ### Generate the start and end observation parameters $date_obs = "$startday-$s_month-$startyear $starthour:$startminute"; $date_end = "$endday-$e_month-$endyear $endhour:$endminute"; ### Connect to the database $dbh = DBI->connect("DBI:Oracle:$sid", $user, $pass) || die "Cannot connect to database: $DBI::errstr\n"; ### Issue the query #$sth = $dbh->prepare(qq{ select id_obs,date_obs, date_end, XCEN, YCEN from observation where id_instrume=7 AND date_obs >= \'$date_obs\' and date_end <= \'$date_end\' }); $sth = $dbh->prepare(qq{ select id_obs,date_obs, date_end, XCEN, YCEN from observation where id_instrume=7 AND date_obs >= \'$date_obs\' and date_end <= \'$date_end\' }); $sth->execute(); ### Display the output (HTML) print "Content-type: text/html\n\n"; print "
"; print "
  • Searching for observations between: $date_obs and $date_end
    "; print "
    Date end: $date_end\n"; print "\n"; while (@ary = $sth->fetchrow_array()) { print "\n"; foreach $field (@ary){ chomp($field); print " \n"; } print "\n"; } print "
    $field
    "; $dbh->disconnect();