Here is the function for this query:
sub Query_TotalBatches() { my($Rows, $Prepare_Batch, $RowValue_Batch, $RowValue_Count); my @ColumnsValues = (); $Query_String_Batch = "select left(B.B_num,3) as JD, sum(B.B_COUNT +) as Doc_Cnt, P.PROJECTED_VOL as Proj_Vol, P.DATAMARK_RECD as DataMar +k_Recd, P.JD_CURRENT as JD_Current, P.JD_FUTURE as JD_Future from $TB +L_NAME B left join $TBL_PROJVOL P on P.REPORT_IMPORT_DT = B.REPORT_IM +PORT_DT where B.REPORT_IMPORT_DT =?group by left(b_num,3)"; $Prepare_Batch = $dbh->prepare($Query_String_Batch); print "1 = $Query_String_Batch\n";<stdin>; $RowValue_Batch = $Prepare_Batch->execute($ReportDate) || print "E +rror : ".$dbh->errstr."<\/p>"; $RowsFlag = False; if ( $RowValue_Batch > 0 ) { my $RowCount = 0; while ( $Rows = $Prepare_Batch->fetchrow_hashref ){ $ColumnsValues[0] = $Rows->{JD}; $ColumnsValues[1] = $Rows->{Doc_Cnt}; $ColumnsValues[2] = $Rows->{Proj_Vol}; $ColumnsValues[3] = $Rows->{DataMark_Recd}; $ColumnsValues[4] = $Rows->{JD_Current} if ($RowCount == 0 +); $ColumnsValues[4] = $Rows->{JD_Future} if ($RowCount == 1) +; $DailyReport{TB}{$ColumnsValues[0]} = [ @ColumnsValues ]; $DailyReport{TB}{DocCount} += $Rows->{Doc_Cnt} if (length( +$Rows->{DocCount})>0); $DailyReport{TB}{ProjVolume} += $Rows->{Proj_Vol} if (leng +th($Rows->{DocCount})>0); $DailyReport{TB}{DMIReceived} += $Rows->{DataMark_Recd} if + (length($Rows->{DocCount})>0); # $DailyReport{TB}{JDCount} = ($Rows->{JD_Current} + $Rows +->{JD_Future}) if (length($Rows->{JD_Current})>0 and length($Rows->{J +D_Future})>0); $RowCount++; # Print "1 = @ColumnsValues = $DailyReport{TB}{DocCount} = +$DailyReport{TB}{ProjVolume} = $DailyReport{TB}{DMIReceived} = $Daily +Report{TB}{JDCount}\n";<stdin>; } } }
Edited by planetscape - added code tags
In reply to Re^2: Perl DBI Error
by pdl_babu
in thread Perl DBI Error
by pdl_babu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |