I've verified via print statements that $attrHash->{OBJECT} is getting the correct values on each iteration through the loop, but when I look at the result returned, there are the correct number of them, but they all contain the value of the last row retrieved by the SQL.sub selectAttributesForReport { my ($self, $viewName) = @_; my $result; my $attrHash; ### SQL TO GET THE DATA ### my $dbm = $self->getDBManager(); my $sqlText = $dbm->getSQL('selectAttributesForReport'); my $dbh = $dbm->getDBH(); my $sth = $dbh->prepare($sqlText); $self->logger_sql->info("Executing SQL: $sqlText"); $sth->execute($viewName); #push the data onto our results while ( my $resultRowRef = $sth->fetchrow_hashref() ) { $attrHash->{OBJECT} = $resultRowRef->{'ATTRNAME'}; $attrHash->{OBJECTATTRIB} = $resultRowRef->{'ATTRNAME2'}; push (@$result, $attrHash); } ##There were no results. if(not $result) { $self->logger->error("There was no information available for t +he view: [$viewName]"); } return $result; }
I'm sure I'm doing something dumb on the push, but I can't put my finger on it.
In reply to Problem pushing hashref results by rashley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |