I have seen code like this to handle errors when you retrieve a row count in sql
(my $buddy_count = $dbh->selectrow_array ("SELECT COUNT(*) FROM profil
+e") ) or die "query failed"
I assumed that this query only returned undef if there was an error but looking at the docs i am wrong.
Also, in a scalar context, an undef is returned if there are no more r
+ows or if an error occurred. That undef can't be distinguished from a
+n undef returned because the first field value was NULL. For these re
+asons you should exercise some caution if you use selectrow_array in
+a scalar context, or just don't do that.
so you can't tell with the code if there was an error or no more rows - but a select count should always return one row unless there is an error? So, what is the proper way of doing this?
I have also read you should always use individual prepare and execute statements when executing select queries. What do you think about that?
Also when handling database errors is it 'better' to set RaiseError = 1 or handle the errors yourself manual with or diechecks. I've seen this link
http://docstore.mik.ua/orelly/linux/dbi/ch04_05.htm and i think the upshot is to use RaiseError=1 as the code is cleaner and easier to read. What do you think?
thanks a lot