473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

how to fetch one row at a time

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
1 1930
RonB
589 Expert Mod 512MB
See my answer on your cross post.

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

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

Similar topics

1
by: Ann | last post by:
Hello everyone, hope someone can help me with this. I have a SQL stored procedure that inserts a record into a table, creates a cursor to fetch the last record that was added to get the unique...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
2
by: Michel Esber | last post by:
System scenario: Linux DB2 Workgroup Server V7 FixPack 13. I have a java application (JDBC v2 driver) that reads into memory a considerable amount of data (100k-300k rows), summarizes the...
1
by: Fredrik Rodin | last post by:
All, I've been trying to get this question answered before and I got some hints, but nothing that really fit my needs. Here's what I'm aiming at: I create x number of LinkButton at run-time...
9
by: Acupuncture | last post by:
Hi, I am developing a JDBC application and I encountered this problem (DB2 for ISeries). I want to do a select for update and also use the fetch first rows clause. This is my sql statement: ...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
2
by: Sally1053 | last post by:
can you please give me an example of using the FETCH and cursor statement And make to be able to fetch more that one row at a time, lets say the two database are TEST(fetch to) and TLC (fetch...
3
by: camarun20 | last post by:
Hi , I constructed an MS access query in java to retrieve the rows in random. The code snipet Connection con = DriverManager.getConnection( database ,"",""); Statement s =...
0
by: Rilly | last post by:
Anyone use PowerMovielist here? I have the 0.14 beta version. Do you have a problem where some shows you search for cause the fetch to hang ? I'm pulling my hair out on this.. For example, I search...
4
by: robin1983 | last post by:
Dear All, How are you doing? After a long time I am back again because I need help from you all expert. Please advise me, my queries is given below. I have a table with employee_name which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.