
sarthakganguly
Novice
Jul 25, 2009, 11:34 PM
Post #1 of 5
(8035 views)
|
SELECT Finding if result returned is 0
|
Can't Post
|
|
Hi, I have the following script for fetching some data from mySql DB. my $query_select_groups="SELECT GROUPS.group_id,GROUPS.article_id FROM GROUPS WHERE group_id = (SELECT DISTINCT GROUPS.group_id FROM GROUPS LIMIT 1) AND flag=0"; my $query_select_groups_handle = $connection->prepare($query_select_groups); $query_select_groups_handle->execute() or die "Error in fetching data"; query_select_groups_handle->bind_columns(\$group_id,\$article_id); while($query_select_groups_handle->fetch()){ print "group id $group_id \n "; print "article id $article_id \n"; push(@articles,$article_id); } If the query returns 0 rows I want the program to sleep for 30 secs and try again. q1)How to find if the query is returning 0 or not? Is this going to help ....? if($query_select_groups_handle->{NUM_OF_FIELDS} eq 0){ goToSleep(); } q2)If some error occurs I dont want the program to die..I want it to log and go to sleep. For dat instead of $query_select_groups_handle->execute() or die "Error in fetching data"; what can I use? Please suggest me some solutions... Thanks in Advance Thanking you regards Sarthak
|