Re: Get count of records from SELECT - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Get count of records from SELECT
Date
Msg-id 20051115122757.GF7519@svana.org
Whole thread Raw
In response to Get count of records from SELECT  (Zet <skyer@on.kg>)
List pgsql-general
On Tue, Nov 15, 2005 at 05:56:27PM +0300, Zet wrote:
> Hi
>
> I have example:

<snip>

> -- here I will get count of records in "rnum", but I need in LOOP's
> -- first step

You can't, because by that stage the query hasn't finished running yet.
What you need to do is put the output for the query in a temporary
table. Then GET DIAGNOSTICS will have the rowcount. Then you can loop
over that table.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Zet
Date:
Subject: Get count of records from SELECT
Next
From: Christopher Browne
Date:
Subject: Re: Choosing PostgreSQL as the database for our next project