cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
I run this to get a value and it works fine. I then run it again to get another value (from the same field only with a different where condition) and it returns nothing.sub getsqlvalue { my @results = (); my ($dbh,$sqlstatement)= @_; my $sth = $dbh->prepare($sqlstatement); my @row; $sth->execute || die "Could not execute MySQL statement: $sqlstate +ment"; while (@row=$sth->fetchrow_array) { push(@results, [ @row ]); } $sth->finish(); return $results[0][0]; }
So I set a breakpoiint in the debugger inside this sub and copied and pasted the contents of $sqlstatement into the MySQL command line client, and it gave the proper value. I then continued execution, and the value came back null. DBI returns no errors.
What could explain this?!? How can I debug?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI not returning value that MySQL client does
by graff (Chancellor) on May 19, 2010 at 01:23 UTC | |
by mje (Curate) on May 19, 2010 at 10:18 UTC | |
by cormanaz (Deacon) on May 19, 2010 at 03:25 UTC |