Hi Paul,

Thanks for your reply.
 
> The problem here is to do with $anz_dbf_db.
> 
> You have correctly noted that this is an array reference.  To print in
out you
> have used "@$anz_dbf_db", which has printed the elements of the array,
> separated by spaces.  This has shown you that there is one element of
the
> array, 141.

Sorry, but no - since I do a 'select count(*)...' I get back exactly one
value representing the number of matches from the select. So this '141'
is the result of the sql...
 
> However, when using the array in a comparison, you have used
> @$anz_dbf_db again, but this time in scalar context.  Here, you have
asked
> for the number of elements in the array, which is one.  You can test
this by
> adding DEBUG(scalar @$anz_dbf_db);  This is why the comparison is
failing -
> 1 != 141.
> 
> So you should really be testing against $anz_dbf_db->[0] in your
comparison.
> Or better yet, in section two you should make $anz_dbf_db the actual
> number you are looking for, rather than the array ref you are getting
back.

I changed my code to the following:

my $anz_dbf_db_select = $dbh->selectcol_arrayref($sth); # holt alle
Inhalte der 1. Spalte in eine Array-REFERNZ!!!
$sth->finish();
my $anz_dbf_db;
if ( ! @$anz_dbf_db_select ) { # Array-REFERENZ!!!, Error, wenn DB nicht
gelesen werden kann  <-- changed the variable name here
    LOGWARN("$fnc - Datenbank konnte nicht gelesen werden:
$DBI::errstr\n");
    $rcs { "$fnc" } = (1);
} else {
    $anz_dbf_db = $$anz_dbf_db_select[0]; # <-- and saved the value into
another scalar here
}

Works fine now - thank you so much for your help! :-)

Cheers,
Nora


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to