Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8859971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:10:39+00:00 2026-06-14T15:10:39+00:00

I ran into a problem when running code similar to the following example: my

  • 0

I ran into a problem when running code similar to the following example:

my $rows = $dbh->do('UPDATE table SET deleted=NOW() WHERE id=?', undef, $id) 
  or die $dbh->errstr;
if (!$rows) {
  # do something else
}

Since the docs state that do returns the number of rows affected, I thought that would work.

Prepare and execute a single statement. Returns the number of rows
affected or undef on error. A return value of -1 means the number of
rows is not known, not applicable, or not available.

As it turns out, I was mistaken. When I debugged it, I saw that $rows in fact holds the string 0E0, which of course is a true-ish value. I dug in the docs further and saw this piece of code:

The default do method is logically similar to:

  sub do {
      my($dbh, $statement, $attr, @bind_values) = @_;
      my $sth = $dbh->prepare($statement, $attr) or return undef;
      $sth->execute(@bind_values) or return undef;
      my $rows = $sth->rows;
      ($rows == 0) ? "0E0" : $rows; # always return true if no error
  }

There it is. It returns 0E0. I just don’t get why it would do that. Does anyone know?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:10:40+00:00Added an answer on June 14, 2026 at 3:10 pm

    It’s a true value, so you can distinguish it from the false value it returns on error, yet it’s numerically equal to zero (without warning), so it’s still equal to the number of records affected.

    $ perl -e'
       for (undef, "0E0", 4) {
          if ($_) {
             printf "Success: %d rows affected\n", $_;
          } else {
             print "Error!\n";
          }
       }
    '
    Error!
    Success: 0 rows affected
    Success: 4 rows affected
    

    If 0 was returned on success when no records are affected, you’d be forced to check errors using defined, which is far less convenient than testing for truth (e.g. foo() or die;).

    Other true zeroes. (Ignore "0x0"; it warns.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I ran into a problem with some C code like this: struct SomeType {
I ran into the following problem: I'm customizing the whole appearance of my app.
I'm running into a strange problem when using unittest.assertRaises . When executing the code
I ran into a problem... perhaps someone bumped into something similar: I have an
I'm running into a problem with the WPF TreeView control. I think I ran
I ran into a problem using Springsource Tool Suite when writing some groovy scripts
I ran into a problem that suggests I may be implementing a design pattern
I ran into a problem or maybe even a MySQL limitation. The situation is
I ran into a problem today trying to override an implementation of an interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.