my $QUERY = "select READ_COMMUNITY,IP_ADDRESS,DEVICE_GROUP,MANAGED from SNMP_NODES"; # Do your connect, prepare, execute, etc... my $dbh = DBI->connect($DB_DSN, $DB_USER, $DB_PASS, $DB_OPTIONS) or die "Couldn't connect to DB: " . $DBI::errstr; my $sth = $dbh->prepare($QUERY) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute(); ### Map the node definition fields to the SQL result columns ### my $RESULT_MAP = { 'read_community' => 'READ_COMMUNITY', 'address' => 'IP_ADDRESS', 'on_off' => 'MANAGED', 'group' => 'DEVICE_GROUP', }; my $bound_fields = bind_result_columns($sth, $RESULT_MAP); while ($sth->fetch) { # Do stuff with the data now... print Dumper $bound_fields; # DEBUG }