$sth->execute($foo, $bar, $rat) or die $sth->errstr, $/; my $r = $sth->fetchrow_arrayref; my $sum = $r ? $r->[0] : 0; $sth->finish;