rashley has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem pushing hashref results
by davorg (Chancellor) on Oct 26, 2006 at 15:57 UTC | |
by bart (Canon) on Oct 27, 2006 at 15:24 UTC | |
|
Re: Problem pushing hashref results
by bobf (Monsignor) on Oct 26, 2006 at 16:11 UTC | |
|
Re: Problem pushing hashref results
by caelifer (Scribe) on Oct 26, 2006 at 17:27 UTC | |
by caelifer (Scribe) on Oct 26, 2006 at 17:30 UTC | |
|
Re: Problem pushing hashref results
by rashley (Scribe) on Oct 26, 2006 at 16:19 UTC |