Re: Get count of records from SELECT

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Zet <skyer(at)on(dot)kg>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Get count of records from SELECT
Date: 2005-11-15 12:27:58
Message-ID: 20051115122757.GF7519@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Judicaël Dehotin 2005-11-15 12:59:29 recovering windows database after crash
Previous Message Michael Glaesemann 2005-11-15 10:25:27 Re: 3 x PostgreSQL in cluster/redunant