Re: Number of rows in a cursor ?

From: <neil(dot)saunders(at)accenture(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Number of rows in a cursor ?
Date: 2005-08-24 10:00:54
Message-ID: B74B7433CDDD2C4AA41D94832E32E19D92EE9A@EMEXM1112.dir.svc.accenture.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You cannot count the number of rows in a cursor, unfortunately. I recently ran in to this problem.

As far as I am aware, the only way to count them is to either iterate through them,
or if you are only expecting one or two, perform multiple FETCHES and test if the
record set returned is empty.

http://archives.postgresql.org/pgsql-sql/2005-08/msg00208.php

OPEN cur_overlap FOR EXECUTE 'SELECT *, ....';

FETCH cur_overlap INTO row_one;
FETCH cur_overlap INTO row_two;

IF (row_two.id IS NULL) THEN ....

King regards,

Neil.

This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Szűcs Gábor 2005-08-24 10:03:14 Re: Tuple insert missing query in ongoing transaction
Previous Message Thomas Borg Salling 2005-08-24 09:55:01 Re: Number of rows in a cursor ?