in reply to DBI forgets last record

A couple of valid solutions have been shown, here's another take on the problem (I consider this to be a more natural way of solving it):

my $rows = 0; while ( defined( my ($id,$prod_id,$qty) = $sth->fetchrow_array()) ){ ++$rows; print "====== $id =====<br>"; # for testing } print "NO ITEMS IN CART" unless $rows > 0;

Hope this helps.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Replies are listed 'Best First'.
Re: Re: DBI forgets last record
by Brutha (Friar) on Jan 09, 2003 at 09:59 UTC
    Thanks for the DBI Hints. But talking about 1st and last row, I would like to add a reminder for the SQL:

    Never count on the order of rows in an SQL-Select unless you use order by. Even if every day experience may tell you something different and you use tricks like indices etc, but that is just by accident. The result is a set, which is unordered per definitionem.

    It is just the first row that gets lost, but that gives no clue about the contents of the row.