in reply to Find empty tables - sqlite module

0E0 is a DBI shorthand meaning no rows returned/affected on a successful query. See the DBI docs for more-

For a non-SELECT statement, execute returns the number of rows affected, if known. If no rows were affected, then execute returns "0E0", which Perl will treat as 0 but will regard as true. Note that it is not an error for no rows to be affected by a statement. If the number of rows affected is not known, then execute returns -1.

Replies are listed 'Best First'.
Re^2: Find empty tables - sqlite module
by bubnoff (Novice) on Jan 01, 2009 at 00:17 UTC

    Thanks for clarifying that! The following code works:

    my $empty5 = $dbh->selectall_arrayref("SELECT count(item) FROM audio"); foreach my $row (@$empty5) { my ($count) = @$row; if ( $count > 1 ) { print "Processing $count Items\n"; &processItem; } else { print "No Items\n"; &noItems; } print "$count\n"; }

    I figured that selectall_arrayref might be the key, but it took a little experimentation to hone it to what I needed.

    Thanks again for your answer!

    Bubnoff

      That seems like overkill for what you are looking for,

      my ($counted) = $dbh->selectrow_array("SELECT COUNT(*) FROM audio"); print "No. Rows: $counted\n";
Re^2: Find empty tables - sqlite module
by Marshall (Canon) on Jan 01, 2009 at 06:49 UTC
    To clarify more (or not), 0E0 is 0 x 10**0 =0 x 1 =0
    Ooops...my goof before.... This is the Perl way to return a "true", "zero value".
    I like most, seldom use exponential notation in Perl, but that is what this is.

      Oh, nice. I didn't realize that but it's obvious once you hear it.

      moo@cow[74]~/bin>perl -le 'print eval "0E0"' 0 moo@cow[75]~/bin>perl -le 'print eval "10E0"' 10 moo@cow[76]~/bin>perl -le 'print eval "10E1"' 100 moo@cow[77]~/bin>perl -le 'print eval "10E10"' 100000000000