in reply to While loop seems to miss data

$sth->trace( 2 ) might prove enlightening. Look for the section "TRACING" in the DBI perldocs for more details.