Get count of records from SELECT

From: Zet <skyer(at)on(dot)kg>
To: pgsql-general(at)postgresql(dot)org
Subject: Get count of records from SELECT
Date: 2005-11-15 14:56:27
Message-ID: 5421621000.20051115175627@on.kg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I have example:

rnum := 0;
FOR r IN EXECUTE ''SELECT *
FROM ''||table_name||''
WHERE var = ''||var
LOOP
IF rnum = 0 THEN
-- how could I get the count of records here ???
-- I tried GET DIAGNOSTICS rcount = ROW_COUNT;
-- BUT it returns ZERO = 0 :(
END IF;
rnum := rnum + 1;
END LOOP;

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

Many thanx from Zet

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Berend Tober 2005-11-15 15:07:03 Most significant digit number formatting
Previous Message Christopher Browne 2005-11-15 13:32:13 Re: Choosing PostgreSQL as the database for our next project