I wrote a script to run a few select queries from a database using the DBI
module. The script works, but occasionally times out and either the query
results are truncated, or I get 'The page cannot be displayed'.

Is there a timeout parameter somewhere that I could increase in Apache, or
Perl?

I don't think the code is needed, but I've seen it asked for in the past, so
here it is:


#!/usr/bin/perl
#       
#       
#       
#       
#       
#
#
# Set up the basics
#
BEGIN {
    $ENV{ORACLE_HOME} = q{/opt2/oracle/ora817};
    $ENV{TWO_TASK}    = q{RPT2};
}

use strict;
use CGI qw(:standard);
use warnings;
use DBI;
#use clarify;


#
# Set up the basics
#
BEGIN {
    $ENV{ORACLE_HOME} = q{/opt2/oracle/ora817};
    $ENV{TWO_TASK}    = q{SID};
}
my $caseCnt = 0;
my @qString = split(/\=|\&/, $ENV{QUERY_STRING});
my $ownQuery = param("myOwnQuery") || '';
my $orderBy = param('sortOrder') || 'owner';
my @noReport = param('product') || 'NULL';
my $isConnected = 'FALSE';
my $defaultReport = '';
my $oraSid = 'SID';
my $oraUser = 'USER';
my $oraPass = 'PASSWD';
my ($thisRep, $thisSid, $thisUser, $thisPass, $dbh, $field) = '';
my @eachRow = '';
my $rep = '';

sub connectRPT2
{
        $thisRep = $_[0];
        $thisSid = $_[1];
        $thisUser = $_[2];
        $thisPass = $_[3];

        if ($isConnected eq 'TRUE')
        {
           getReport($thisRep);
        }
        else
        {
           $isConnected = 'TRUE';
           $dbh = DBI->connect("dbi:Oracle:$thisSid", "$thisUser", "$thisPass");
           getReport($thisRep);
        }
        return 1;
}

sub getReport
{
        #######
        my $sth = $dbh->prepare("
                        select id_number, owner, status, first_name, last_name, 
site_name, title, creation_time
                        from SA.TABLE_QRY_CASE_VIEW
                        where condition = \'Open\' and
                        x_product = \'$thisRep\'
                        order by $orderBy");
        $sth->execute();
        print "<a href=\"http://irvsupu13/reports.php\";>Back</a><br>\n";
        print "<b>$rep:</b><br>\n";
        print "<table border=1 width=1200>\n <tr bgcolor=aaaaaa>\n  ";
        print 
"<td><b>CaseID</td><td><b>Owner</td><td><b>Status</td><td><b>First</td>
           
<td><b>Last</td><td><b>Site</td><td><b>Title</td><td><b>Created</td></tr>\n";

         while (@eachRow = $sth->fetchrow_array)
         {
                print " <tr>\n";
                foreach $field(@eachRow)
                {
                        print "<td>$field</td>";
                }
                $caseCnt++;
                print " </tr>\n";
         }

        print "<tr>\n <td colspan=2>\n";
        print "<b>Open cases:<br># of cases opened in 2005:<br># of cases in 
development\n";
        $sth->finish;

        #######

        $sth = $dbh->prepare("select count(*) from SA.TABLE_QRY_CASE_VIEW
                              where x_product = \'$thisRep\'
                              and creation_time like \'%-05\'");
        $sth->execute();
        @eachRow = $sth->fetchrow_array;
        print "</td><td colspan=6>\n";
        print "$caseCnt<br> $eachRow[0] <br>*** Need a way of tracking this 
number for each product\n";


        $sth->finish;
        print "</td></tr></table>\n";
        $caseCnt = 0;
        return 1;
} 

sub disConnectRPT2
{
        $dbh->disconnect;
        return 1;
}



print "Content-type: text/html\n\n";
print "\n\n";
print "<html>\n<head>\n<title>Product Reports</title>\n";
print "<style>
* {     
        font-size:      12;
        font-face:      courier;
     }
</style>\n</head>\n<body bgcolor=eeeeee>\n";

print "\n\n\t<!-- start -->\n<div align=center>\n ", strong('Clarify Reports'), 
"\n",
        hr, "\n</div>\n";
foreach (@qString)
{
  if ($_ =~ m/open/)
  {
        SWITCH:
        {
           $_ eq 'Unkopen' && do { next; last SWITCH; };
           $_ eq 'QCSSopen' && do { $rep = "Quest Central for SQL Server"; last 
SWITCH; };
           $_ eq 'QCSSDGopen' && do { $rep = "QCSS Data Generator"; last 
SWITCH; };
           $_ eq 'IWopen' && do { $rep = "I/Watch"; last SWITCH; };
           $_ eq 'BBopen' && do { $rep = "Big Brother"; last SWITCH; };
           $_ eq 'LeccoSSopen' && do { $rep = "Lecco SQL Expert for SQL Svr"; 
last SWITCH; };
           $_ eq 'QCSSDAopen' && do { $rep = "QCSS Database Analysis"; last 
SWITCH; };
           $_ eq 'QCSSDBAopen' && do { $rep = "QCSS Database Administration"; 
last SWITCH; };
           $_ eq 'QCSSKXopen' && do { $rep = "QCSS KnowledgeXpert"; last 
SWITCH; };
           $_ eq 'QCSSLGopen' && do { $rep = "QCSS Load Generator"; last 
SWITCH; };
           $_ eq 'QCSSSMopen' && do { $rep = "QCSS Space Management"; last 
SWITCH; };
           $_ eq 'QCSSSDopen' && do { $rep = "QCSS Spotlight Diagnostics"; last 
SWITCH; };
           $_ eq 'QCSSSTopen' && do { $rep = "QCSS SQL Tuning"; last SWITCH; };
           $_ eq 'QCSSPAopen' && do { $rep = "QCSS Performance Analysis"; last 
SWITCH; };
           $_ eq 'SoSSopen' && do { $rep = "Spotlight on SQL Server"; last 
SWITCH; };
           $_ eq 'KXSSopen' && do { $rep = "Knowledge Xpert for SQLServer"; 
last SWITCH; };
           $_ eq 'FogSSopen' && do { $rep = "Foglight Cartridge for SQL Svr"; 
last SWITCH; };
           $_ eq 'ToadSSopen' && do { $rep = "Toad for SQL Server"; last 
SWITCH; };
        }


        connectRPT2($rep, $oraSid, $oraUser, $oraPass);
        print "\n", br;
  }
  else
  {
        next;
  }
}

if($ownQuery)
{
   print hr, "\n";
   print $ownQuery, "\n\t<!-- Done --><br>\n\n";
}

if ($noReport[0] eq 'NULL' && $ownQuery eq '')
{
        print "No Report\n";
}
else
{
        disConnectRPT2();
}
print "\n", br;
print "<a href=\"http://irvsupu13/reports.php\";>Back</a><br>\n";
print end_html;


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to