I have two question related to the question below:
1.      Is fetchrow() the fastest way in and out of the DB?  I don't want
the data warehouse tied up while someone is loading a huge report.
2.      I would like to create frames with CGI so the list stays on the left
side and the data is displayed on the right.

#! /usr/local/bin/perl

use CGI;
my $query = new CGI;
$ENV{ORACLE_HOME} = "/opt/app/oracle/product/8.1.7";
use DBI;

$guess = "";
$oserver = "dwhs";
$ouser = "sward";
$opasswd = "notgonadoit";
$ora_dbh = DBI->connect("dbi:Oracle:$oserver", $ouser, $opasswd) 
        || die "Can't connect to $data_source: $DBI::errstr";

$list_name = $query->param('list_name');
$day_list = $query->param('day_list');

#print "day_list = $day_list
#print "list_name = $list_name \n";

        if (! $list_name) 
{ 
                print $query->header;   
                print $query->start_html(
                                          -title=>'Casual Reports',
                                          -BGCOLOR=>'3366CC');
                
                        
                print $query->startform("POST","/cgi-bin/steftest.cgi");
                print $query->popup_menu(-name=>'list_name',
                                         -align=>'left',
                                       -values=>[
                                                'Total_games_sold',
                                                'Yadda',
                                                'Yoda',
                                                'Ugo',  
                                                ],
},      
                                                -default=>[''],
                                                -size=>'1');
                print "\n";

                print $query->popup_menu(-name=>'day_list',
                                            -align=>'left',
                                               -values=>[1,7,30],
                                               -labels=>
{
                                        '1'=>'1 day back',
                                                '7'=>'One week back',
                                                '30'=>'One month back',
                                                },      
                                            -default=>[''],
                                                    -size=>'1');
                               
                                
        print $query->submit(
                                       -name=>'button_name',
                                   -align=>'left',
                               -value=>'value'
                                       );

        print $query->endform;  
        print $query->end_html;
        print "\n";
}

        else {
                $ora_sth = $ora_dbh->prepare ( q
{
                select
                        timestamp,
                        report_type,
                        data_name,
                        data_value,
                from
                        dwhs.mainstream_games_reports
                where
                        report_type = ? and
                        timestamp >= (sysdate - ?) 
}  
        )  || die "Can't prepare statement: $DBI::errstr";

$rc = $ora_sth->execute($list_name, $day_list) || die "Can't execute
statement: $DBI::errstr";


$query = new CGI;
print $query->header,
$query->start_html(-title=>'Action Game Report',
                        -BGCOLOR=>'3366CC');
print "\n";

print $query->start_table({-border=>undef,
                                -align=>'center'});
print "\n";

print $query->Tr( $query->th(['Date', 'Report Name', 'Data Name', 'Value'])
);
print "\n";

        while ( ($timestamp, $report_type, $data_name, $datavalue) =
$ora_sth->fetchrow_array)
{
        print $query->Tr( $query->td([$timestamp, $report_type, $data_name,
$datavalue]) );
        print "\n";
}

$ora_dbh->disconnect;
print $query->end_table;
print "\n";
print $query->end_html;
print "\n";

}

Reply via email to