Row count after SELECT INTO?

From: "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Row count after SELECT INTO?
Date: 2004-04-07 19:04:26
Message-ID: 20040407190426.GI41029@dyatel.antar.bryansk.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear SQL and plPgSQL gurus, I seek for your wisdom.

I have a variable assignment via SELECT INTO in my function, and I want
to separate 3 cases:
1) no rows found;
2) one row found;
3) many rows found (ambiguous select).

The first case is simple, I use FOUND variable for it.
But how about the third? I tried to GET DIAGNOSTICS nrows = ROW_COUNT,
bit it seems to get only value of 0 or 1. Is this how it supposed to be
when SELECTing INTO a single variable?

The only way I see now is a FOR ... IN SELECT loop, and I woner if
there is a simpler solution. Could you please help me?

--
Fduch M. Pravking

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Reina 2004-04-07 19:32:53 Re: Help with COPY command
Previous Message Tom Lane 2004-04-07 18:27:03 Re: notify and leaks?