Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PERL
my $dbHit= $DB->prepare($db_statement);
	$dbHit->execute();
	my $isHoliday = 'f';
	while (my @key=$dbHit->fetchrow()){	
		my $account			= padZero($key[0],9);
		my $tdate			= $key[1];
		my $code			= $key[3];
		my $item			= $key[2];
		my $default			= 'CMB';
}


The problem is I'm executing a query which return zero rows. We are using while with dbhit values in it. What will happen. Will the while loop execute or not.
Posted
Updated 27-Jun-12 9:33am
v2

1 solution

Well how hard would it be to just try it?

Another way to look at it is: how would returning zero rows be different to fetchrow() than the second iteration if there was only one row returned? Either way you get an empty list and the while ends (which is the point of this structure). So, if you have no row, you get no iteration.

Still, you should try it, run it in the debugger even. It may help you to better understand what's going on.

By the way, while DBI does have a deprecated fetchrow(), it would be better form to use fetchrow_array() in your while.

hope this helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900