On Fri, 19 Apr 2002 15:14:20 +0200 (CEST) Michael Spellbrink
<[EMAIL PROTECTED]> wrote:
> my $sql = <<SQL;
> select
> ROUND((total_blocks-unused_blocks)/total_blocks*100),
> ROUND((((hwm+1)-
> last_used_block)/total_blocks)*100)
> from M_stats_tab_us
> where M_stats_tab_us.Tabelle = ?
> and m_stats_tab_us.dp_nr = ?
> and owner = ?
> order by datum
> SQL
# You might want to add more to the die() messages.
# Usually you can tell what happened from the text of
# $DBI::errstr, but not always.
> my $sth = $dbh->prepare( $sql ) || die
> "$DBI::errstr";
>
> $sth->execute( $tabelle,$node,$owner ) || die
> "$DBI::errstr";
>
> ####
> my( $statist,$differ, @statist,@differ );
> $sth->bind_columns( \$statist,\$differ);
my $rowcount = 0;
> while( $sth->fetch() ) {
++$rowcount;
> push (@statist,$statist);
> push (@differ,$differ);
> }
die "Error during fetch, $DBI::errstr\n" if $DBI::err;
print "Fetched $rowcount rows\n";
# $sth->finish is deprecated when all rows are being fetched
> $sth->finish();
>
>
> all i want to do is getting the results of the query
> (more than one row into @differ and @statist.
> but the arrays are always empty after ->finish
The biggest problme I see is that you are not doing any error checking
after the loop. It appears that no rows are being fetched, but without
error checking or at least a counter in the loop, you have no idea what is
going on. I've inserted some suggested statements above.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.htm
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.