X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 63E5BD1C9DA for ; Fri, 1 Aug 2003 11:25:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33390-09 for ; Fri, 1 Aug 2003 08:24:00 -0300 (ADT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id B105ED1C4D5 for ; Fri, 1 Aug 2003 08:25:02 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Fri Aug 01 13:25:01 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id NAA01479; Fri, 1 Aug 2003 13:25:00 +0200 (METDST) Message-ID: <3F2A4E0C.AB433D8@rodos.fzk.de> Date: Fri, 01 Aug 2003 13:25:00 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org, k.p.lehre@tiscali.no Subject: Re: length of recordset read through a cursor Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char 9C hex) in message header 'Received' Received: \234by rodos.fzk.de... ^ X-Archive-Number: 200308/2 X-Sequence-Number: 14618 > > After declaring a cursor, one way of obtaining the length of the resultset > is to perform a "MOVE 0" and read the PQcmdStatus which returns a "MOVE nn" > where nn is the length of the resultset. (A negative MOVE can then be used > to allow starting to fetch records from the beginning of the resultset.) > > Is there another, possibly faster way? > Looks like you're using libpq (because you mention PQcmdStatus), then after declaring a cursor and FETCH ALL, try 1.3.4. Retrieving SELECT Result Information PQntuples Returns the number of tuples (rows) in the query result. int PQntuples(const PGresult *res); I'm not exactly sure what you're trying to achieve or going to do, so if I misunderstood you, ask again. Regards, Christoph