in reply to Perl DBI
If that is total for all tables then consider extracting all the stat1-4 data in 4 queries first to avoid repeat queries for each record in KPI Master. Also consider replacing * in sql with specific fields that you require. This is untested as I don't have a suitable access database but something like this should run in seconds I would hope !
poj#!perl use DBI; use strict; my $dbh = DBI->connect('dbi:ODBC:driver=Microsoft Access Driver (*.mdb +, *.accdb); dbq=D:\Project\Project\BSC_KPIMonitoring\CHN\E_BSC_KPIMonitorDB.mdb'); my @tables = ( 'SDCCHBLOCKING', 'SDCCHDROP', 'TCHBLOCKING', 'TCHDROP', ); my %abbr = ( 'SDCCHBLOCKING' => 'SB', 'SDCCHDROP' => 'SD', 'TCHBLOCKING' => 'TB', 'TCHDROP' => 'TD', ); my $regex = join '|',@tables; # get all data my %db=(); for my $tbl (@tables){ $db{$tbl} = $dbh->selectall_arrayref("SELECT NE,* FROM $tbl"); } my $sql = "SELECT * FROM KPI_Master"; my $sth = $dbh->prepare($sql); $sth->execute; while ( my ($bsc,$kpi,$thresh) = $sth->fetchrow_array() ){ # search table corresponding to kpi if ($kpi =~ /($regex)/){ my $tbl = $1; for ( @{$db{$tbl}} ){ # select records with correct NE value in first column if (( $_->[0] eq $bsc ) && ( $_->[3] > $thresh )){ print "$abbr{$tbl},$bsc,$thresh,/".$_->[3]."\n"; } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl DBI
by Arunkumarpro (Initiate) on Jun 29, 2013 at 20:49 UTC | |
by poj (Abbot) on Jun 30, 2013 at 07:12 UTC | |
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:02 UTC | |
by poj (Abbot) on Jun 30, 2013 at 20:09 UTC | |
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:23 UTC | |
by poj (Abbot) on Jun 30, 2013 at 20:33 UTC | |
by Tux (Canon) on Jul 01, 2013 at 10:51 UTC |