Subject: | PG::PQ cursor fail |
hello,
I'm using your pg::pq module, all works fine, but cursors fail.
The script tells me ST: PGRES_COMMAND_OK ERR:
Then I can't receive any row from output.
with usuall select, if I use:
select * order by ltime desc;
that works.
use strict;
use diagnostics;
use utf8;
use Pg::PQ qw(:pgres_polling);
my $dbc = Pg::PQ::Conn->new(dbname => 'statdb',
user => 'user',
host => 'localhost') or die "cant connect";
$dbc->sendQuery("begin work; DECLARE lists CURSOR FOR select * order by ltime desc; MOVE 0 IN lists; FETCH 9 IN lists; commit work;");
#"select area,quant from kvar;");
while (1) {
$dbc->consumeInput;
last unless $dbc->busy
# do something else
}
my $res = $dbc->result;
my $str = $res->statusMessage;
my $err = $res->errorMessage;
print "ST: $str ERR:$err\n";
if($res){
my @rows = $res->rows;
my $i =0;
while ($rows[$i]) {
print $rows[$i]->[0];
$i++;
}
}
1;
__END__