Search Postgresql Archives

Re: cursores

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 3, 2009 at 9:36 AM, Esneiker <eenriquez@xxxxxxxxxxxxx> 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();

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux