By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,691 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,691 IT Pros & Developers. It's quick & easy.

how to fetch one row at a time

P: 4
Hi,

I have a below subroutine called getqueryresults()


The below function just takes the data from ABC table and returns one row. This function exists in db.pl file
Expand|Select|Wrap|Line Numbers
  1. sub getqueryresults() { 
  2.     my $followerName = $_[0];
  3.      my $sql = "SELECT * ABC WHERE (delay is null or delay < sysdate) AND id = ? ORDER BY qcounter, priority";      
  4.  my $sth = $dbh->prepare($sql);   
  5.   $sth->bind_param(1, $followerName);   
  6.   eval     {         $sth->execute;     };      
  7.     if ($@)     {         $log->error("dbh->errstr());     }    
  8.    if ($sth->rows == -1)     {         $log->error("No  rows.");     }    
  9.  my @data= $sth->fetchrow_array();     return @data; }
  10.  
  11.  
  12.  
  13.  
  14. this below file XX.pl file calls getqueryresults(); 
  15.  
  16.  
  17.   #!/usr/bin/perl   
  18. require 'db.pl';
  19.    $signal = 1;  
  20.  while ($signal)   {
  21.    $signal = &processCommand();   } 
  22.   sub processCommand() {  
  23.   my ($Id, $sId, $rd, $cmd) = getqueryresults("XX");     
  24.   print $Id . "sd==>" . $sId . "rd===>"  . $rd ."\n";    
  25.  return $signal = 1;
  26.  }
  27.  
  28.  


This above print always prints the same row everytime. is there something i am doing wrong. I want to print a next row everytime.

It will be great if someone can take a loot at it.
Mar 3 '10 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 100+
P: 589
See my answer on your cross post.

http://perlguru.com/gforum.cgi?post=...=unread#unread
Mar 3 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.