Skip Menu |

This queue is for tickets about the Pg-PQ CPAN distribution.

Report information
The Basics
Id: 87802
Status: rejected
Worked: 30 min
Priority: 0/
Queue: Pg-PQ

People
Owner: Nobody in particular
Requestors: LSV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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__
You have combined several SQL sentences into one query, PostgreSQL is going to send a response for every one of the sentences. In your particular case, you get a response for "begin work" that's the one you are already handling, then you get another response for "declare ...", another for "move...", another for "fetch..." that's what you were expecting in the first place and finally one for "commit work".