X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A2388D1BB4C for ; Wed, 7 Apr 2004 16:04:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 53755-09 for ; Wed, 7 Apr 2004 16:04:34 -0300 (ADT) Received: from dyatel.antar.bryansk.ru (unknown [195.239.214.85]) by svr1.postgresql.org (Postfix) with ESMTP id 32D5CD1D05C for ; Wed, 7 Apr 2004 16:04:32 -0300 (ADT) Received: from fduch by dyatel.antar.bryansk.ru with local (Exim 4.30; FreeBSD) id 1BBILa-000FPZ-Ob for pgsql-sql@postgresql.org; Wed, 07 Apr 2004 23:04:26 +0400 Date: Wed, 7 Apr 2004 23:04:26 +0400 From: "Alexander M. Pravking" To: pgsql-sql@postgresql.org Subject: Row count after SELECT INTO? Message-ID: <20040407190426.GI41029@dyatel.antar.bryansk.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/60 X-Sequence-Number: 17435 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