title: Why does DBI's do method return "0E0" if zero rows were affected?
body: <p>I ran into a problem when running code similar to the following example:</p>
  
  <pre><code>my $rows = $dbh-&gt;do('UPDATE table SET deleted=NOW() WHERE id=?', undef, $id) 
    or die $dbh-&gt;errstr;
  if (!$rows) {
    # do something else
  }
  </code></pre>
  
  <p>Since the <a href="http://search.cpan.org/~timb/DBI/DBI.pm#do">docs</a> state that <code>do</code> returns the number of rows affected, I thought that would work.</p>
  
  <blockquote>
    <p>Prepare and execute a single statement. Returns the number of rows
    affected or <code>undef</code> on error. A return value of <code>-1</code> means the number of
    rows is not known, not applicable, or not available.</p>
  </blockquote>
  
  <p>As it turns out, I was mistaken. When I debugged it, I saw that <code>$rows</code> in fact holds the string <code>0E0</code>, which of course is a true-ish value. I dug in the docs further and saw this piece of code:</p>
  
  <blockquote>
    <p>The default do method is logically similar to:</p>
  
  <pre><code>  sub do {
        my($dbh, $statement, $attr, @bind_values) = @_;
        my $sth = $dbh-&gt;prepare($statement, $attr) or return undef;
        $sth-&gt;execute(@bind_values) or return undef;
        my $rows = $sth-&gt;rows;
        ($rows == 0) ? "0E0" : $rows; # always return true if no error
    }
  </code></pre>
  </blockquote>
  
  <p>There it is. It returns <code>0E0</code>. I just don't get why it would do that. Does anyone know?</p>