+ my @serviceids = $torrus_srvderive->component_serviceids;
+
+ for my $dir ('_IN', '_OUT') {
+
+ my $sin = join(',', map dbh->quote("$_$dir"), @serviceids);
+
+ my $sum = "
+ SELECT SUM(value) FROM srvexport AS other
+ WHERE other.serviceid IN ($sin)
+ AND $within
+ ";
+
+ my $isql = "
+ INSERT INTO srvexport ( srv_date, srv_time, serviceid, value, intvl )
+ VALUES ( ?, ?, ?, ($sum), ? )
+ ";
+
+ my $isth = dbh->prepare($isql) or die $DBI::errstr; #better recovery?
+ $isth->execute( time2str('%Y-%m-%d', $cur), #srv_date
+ time2str('%X', $cur), #srv_time
+ $serviceid,
+ 300, #intvl ...
+ )
+ or die $isth->errstr;
+
+ }