I have the following subroutine that 99.99% of the time will return a single value. My concern the how do I build in error trapping for the .01% in case there happens to be more than two distinct values. I want to bail.
Code:
sub what_category_do_we_process
{
my $planner = shift;
my ( $cur, $sql );
$sql = "SELECT DISTINCT category
from promo_params
WHERE plnrcode = ?
AND processflag = 'N'";
$cur = $dbh->prepare($sql);
$cur->execute($planner);
$cur->bind_columns(undef, \$category);
while($cur->fetch())
{
return $category;
}
}