1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-03 17:13:17 +03:00
Files
mariadb-columnstore-engine/net-snmp/net-snmp-5.2.1.2/perl/manager/getValues.pm
2016-01-06 14:08:59 -06:00

50 lines
1.2 KiB
Perl

#
# getValues($dbh,
# [-varcol => varname,]
# [-valcol => varval,]
# [-key => keyname,]
# tablename => indexname,
# ...)
package NetSNMP::manager::getValues;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK=(getValues);
my $varcol = "varcol";
my $valcol = "valcol";
my $key = "lookup";
sub getValues {
my $dbh = shift;
my (@vars2, $tmp, $cursor, $row, %results, $i, $cursor);
my ($varcol, $valcol, $key) = ($varcol, $valcol, $key);
my @vars = @_;
while($#vars >= 0) {
$i = shift @vars;
$tmp = shift @vars;
if ($i =~ /^-/) {
$varcol = $tmp if ($i =~ /-varcol/);
$valcol = $tmp if ($i =~ /-valcol/);
$key = $tmp if ($i =~ /-key/);
} else {
push(@vars2,$i,$tmp);
}
}
while($#vars2 >= 0) {
$i = shift @vars2;
$tmp = shift @vars2;
# print "select $varcol,$valcol from $i where $key = '$tmp'\n";
($cursor =
$dbh->prepare("select $varcol,$valcol from $i where $key = '$tmp'"))
or die "\nnot ok: $DBI::errstr\n";
($cursor->execute)
or die "\nnot ok: $DBI::errstr\n";
while ( $row = $cursor->fetchrow_hashref ) {
$results{$row->{$varcol}} = $row->{$valcol};
}
}
return %results;
}
1;