Re: Query and the number of row result

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Query and the number of row result
Date: 2009-09-01 12:49:12
Message-ID: 4A9D1848.9090102@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 31/08/2009 18:00, Tim Landscheidt wrote:

> Presuming that you are talking about a function written in
> PL/pgSQL, you will have to count them yourself or issue a
> second query "SELECT COUNT(*) FROM [...]". For the special
> case that you want to find out whether no row at all was
> found, you can look at "IF (NOT) FOUND".

In pl/pgsql you can also issue a GET DIAGNOSTICS command which gets the
row count:

http://www.postgresql.org/docs/8.4/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

...although it is still has to be done as a second query, as in your
suggestions above.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2009-09-01 13:33:33 Re: pg_ctl with unix domain socket?
Previous Message Josef Wolf 2009-09-01 12:34:00 Re: pg_ctl with unix domain socket?