On Wed, Jun 3, 2009 at 9:36 AM, Esneiker <eenriquez@cav.desoft.cu> wrote:
> Hello.
>
> I´m trying to build a cursor for postgres but I have some problems. Can
> anybody send me an example of cursor in postgres?
In perl:
$dbh->begin_work();
$dbh->do('DECLARE c1 NO SCROLL CURSOR FOR SELECT user_id,user_email
FROM user_list')
or die;
my $sth = $dbh->prepare("FETCH 1000 FROM c1") or die $dbh->errstr;
while (1) {
$sth->execute() or die $dbh->errstr;
last if ($sth->rows() == 0);
while (my ($uid,$email) = $sth->fetchrow_array()) {
print "$uid $email\n";
}
}
$dbh->commit();