Thread: cursores
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?
Thanks.
Ing. Esneiker Enriquez Cabrera.
Excelencia en Software.
Desoft S.A. en Ciego de Ávila.
Joaquín de Agüero Esq. Calle 2. Ciego de Ávila. Cuba.
email:eenriquez@cav.desoft.cu
On Wed, Jun 03, 2009 at 09:36:18AM -0400, Esneiker wrote: > I'm trying to build a cursor for postgres but I have some problems. Can > anybody send me an example of cursor in postgres? What about these examples? http://www.postgresql.org/docs/8.3/interactive/plpgsql-cursors.html - Josh / eggyknap
Attachment
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();