Thank you - that's an excellent lead. I'll give the $dbh->selectall_arrayref a shot.
Re: the placeholder - thanks for the catch, but I had been too sloppy in editing the original code. There is indeed a placeholder:
my $sql_region_id = "select distinct k.id
from config.object o
join config.location l on l.id=o.location
join config.location k on k.id=l.region
order by k.id desc";
my $sql_statement = "select
x.ip,
m.modemmacaddress,
m.date_time,
m.cmtsrxsnr,
m.cmtsrxpower,
m.modemrxsnr,
m.modemrxpower,
m.modemtxpower,
m.microreflections,
m.corrected,
m.uncorrectable,
a.node,
a.addr,
a.street,
a.city,
a.state,
a.zip5,
k.name,
i.ifDescr
from config.object o
join config.location l on l.id = o.location
join config.location k on k.id = l.region and k.id = ?
join nemos.arp x on o.id = x.object
join modem_hist.mh_day_0 m on m.cmtsid = x.object and m.modemmacaddre
+ss = x.mac
join cust.equipment e on e.mac = x.mac
join cust.addr a on a.acct = e.acct
join config.ifdrum i on i.object=o.id and i.ifdrum = x.ifdrum
where o.community is not null and i.ifindex > 0 and
(m.modemtxpower < -15 or m.modemtxpower > 55)
or (m.modemrxsnr < 28)
or (m.modemrxpower < -12 or m.modemrxpower > 12)
or (m.cmtsrxsnr < 25)
or (m.microreflections > 40)
";
unless ( $region_cursor = $dbh->prepare( "$sql_region_id" )){
exit 1;
}
unless ( $region_cursor->execute ) {
exit 2;
}
$region_cursor->bind_columns(\($region_id));
while( $region_cursor->fetch() ){
unless ( $cursor = $dbh->prepare( "$sql_statement" )) {
exit 1;
}
unless ( $cursor->execute($region_id) ) {
exit 2;
}
while( $cursor->fetch() ) {
do stuff...
}
}
|