Counting rows in a PL/PgSQL CURSOR without fetching?

Started by Reg Me Pleaseover 17 years ago2 messagesgeneral
Jump to latest
#1Reg Me Please
regmeplease@gmail.com

Hi all.
Is there a way in PL/PgSQL to get the number of rows resulting from a:
OPEN curs1 SCROLL FOR EXECUTE query;
before actually fetching any?

Unuckily
MOVE LAST FROM curs1;
won't work with
GET DIAGNOSTICS cnt = ROW_COUNT;

Any hint?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Reg Me Please (#1)
Re: Counting rows in a PL/PgSQL CURSOR without fetching?

Reg Me Please <regmeplease@gmail.com> writes:

Unuckily
MOVE LAST FROM curs1;
won't work with
GET DIAGNOSTICS cnt = ROW_COUNT;

Hmm, you're right that MOVE doesn't set row_count (because plpgsql
itself isn't fetching the rows), but it kinda seems like it should.

regards, tom lane