The query should be executed by Oracle, not by the driver, hence the complexity should not matter. As marto said, turn on error reporting.
BTW, you can rewrite "AND (gamm.PROCESS_NAME = 'SAM_Exact_Product_Search' OR gamm.APPLICATION_NAME = 'SAM_Exact_Product_Search')" as "AND 'SAM_Exact_Product_Search' IN (gamm.PROCESS_NAME, gamm.APPLICATION_NAME)" . Get's rid of the OR and only requires the literal once.
trunc(gmz.testtime) will obviate the use of any INDEX on gmz.testtime, better to use AND gmz.testtime >= to_date('09/12/2011','MM/DD/YYYY') AND gmz.testtime < to_date('09/16/2011','MM/DD/YYYY')
IIUC, i don't think you need to specify TO_CHAR in the GROUP BY clause.
For formatting the query, so people can read it, try:
SELECT
gamm.PROCESS_NAME,
GAMM.APPLICATION_NAME,
TO_CHAR(TRUNC(gmz.testtime - 7 / 24, 'DD'),'MM/DD/YYYY')
Fiscal_Day,
ROUND
(
AVG
(
DECODE(total_response_time, 0, NULL, total_response_time)
/ DECODE (total_page_count,0, 1,total_page_count)
)
/ 1000,
2
) Average_Response_time
FROM
portal_gomez_bb_load gmz,
GOMEZ_APP_MAPPING_MASTER gamm
WHERE
gmz.monitor_id = 3805260
AND 'SAM_Exact_Product_Search' IN (gamm.PROCESS_NAME, gamm.APPLICATION_NAME)
AND gmz.testtime >= to_date('09/12/2011','MM/DD/YYYY')
AND gmz.testtime < to_date('09/16/2011','MM/DD/YYYY')
AND success_flag = 0
GROUP BY
gamm.PROCESS_NAME,
GAMM.APPLICATION_NAME,
TRUNC (gmz.testtime - 7 / 24, 'DD');
| [reply] |
use strict;
use Tk;
use Tk::BrowseEntry;
use Tk::LabFrame;
use Tk::JPEG;
use DBI;
use DBD::Oracle;
use Spreadsheet::WriteExcel;
.
.
.
.
.
.
.
sub generateDailyReport{
#Create Excel
my $workbook = Spreadsheet::WriteExcel->new('Report.xls');
my $worksheet = $workbook->add_worksheet();
my $from_date = @_[0];
my $to_date = @_[1];
#Connect to DB
my $dbh = DBI->connect("dbi:Oracle:cecdev9","asdm_dev","c1sc0pass"
+)
or die "cannot connect $DBI::errstr\n";
my $sth = $dbh->prepare("SELECT gamm.PROCESS_NAME, GAMM.APPLI
+CATION_NAME, TO_CHAR (TRUNC (gmz.testtime - 7 / 24, 'DD'),'MM/DD/YYYY
+') Fiscal_Day,ROUND (AVG(DECODE (total_response_time, 0, NULL, total_
+response_time) / DECODE (total_page_count,0, 1,total_page_count))/ 10
+00,2) Average_Response_time FROM portal_gomez_bb_load gmz, GOMEZ_AP
+P_MAPPING_MASTER gamm WHERE gmz.monitor_id = 3805260 AND (gamm.PROC
+ESS_NAME = 'SAM_Exact_Product_Search' OR gamm.APPLICATION_NAME = 'SAM
+_Exact_Product_Search') AND trunc(gmz.testtime) BETWEEN to_date('09/1
+2/2011','MM/DD/YYYY') AND to_date('09/15/2011','MM/DD/YYYY') AND succ
+ess_flag = 0 GROUP BY gamm.PROCESS_NAME,GAMM.APPLICATION_NAME,TO_CH
+AR (TRUNC (gmz.testtime - 7 / 24, 'DD'),'MM/DD/YYYY')");
#execute the query
$sth->execute();
my $i = "A1";
my $j = 1;
while ( my @row = $sth->fetchrow_array( ) ) {
print "@row\n";
$worksheet->write($i, \@row);
$j=$j+1;
$i="A$j";
open(FILE,'Report.xls');
}
}
Please help.
Thanks,
Vidya Surendran | [reply] [d/l] |
| [reply] |
| [reply] |
If it works in Toad or sqlplus but not in your perl code, I'd expect DBD::Oracle to throw some errors* which will point you in the right direction. Are you connecting to the same database as the same user in both Toad and your Perl code? Post a short example of your perl code which reproduces the problem, and any output. See Writeup Formatting Tips.
Update * if it doesn't see DBD::Oracles trace method.
| [reply] |
Is vsurend using DBD::Oracle? Could be DBD::ODBC or something for all we know.
Also, are all the connections really using the same database/username/password/schema? Different connections may point to different tables (similar looking) tables with different content. (e.g. test database vs. production database).
Another thing, especially with Oracle: vsurend, did you compile DBD::Oracle yourself against the Oracle client you have installed on your machine or did you use some precompiled package like ActiveState's PPMs? DBD::Oracle and Oracle's libraries don't always play nice together, even on minor version differences when using a precompiled version.
"Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid… and I went ahead anyway." (Crow in "MST3K The Movie")
| [reply] |