Home: Perl Programming Help: DBI:
Add Dynamic ROWNUM value



sha37
Novice

Mar 3, 2010, 1:05 PM


Views: 7452
Add Dynamic ROWNUM value

  

Code
  

$rowCount++;

my $sql = "SELECT *
FROM
(SELECT
id, sid, rd, cmd
FROM
abc
WHERE
(delay is null or delay < sysdate)
AND
sid = ?
ORDER BY
qcounter, priority)
WHERE
rownum < ?";

my $sth = $dbh->prepare($sql);
$sth->bind_param(1, $followerName);
$sth->bind_param(2, $rowCount);



Will this work? Is this the right way to bind the ROWNUM to get rows.

Well the result will be like this if rownum is < 2

id sid rd cmd

1 zz aa alter

result will be like this if rownum is < 3

1 zz aa alter

2 xx bb edit

I will shift the first value to get the second row and process. Basically i want to process each row at a time.

Thanks

Shamma