X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 5365111F6C19 for ; Thu, 20 Apr 2006 09:35:58 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 required=5 tests=[none] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id DVbLXWg2ADH1 for ; Thu, 20 Apr 2006 09:35:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E192D11F6D3C for ; Thu, 20 Apr 2006 09:35:26 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 5581630CBC; Thu, 20 Apr 2006 14:35:26 +0200 (MET DST) From: "Florian Reiser" X-Newsgroups: pgsql.sql Subject: Re: Moving around in a SQL database Date: Thu, 20 Apr 2006 14:35:24 +0200 Organization: RA Unternehmensberatung Lines: 44 Message-ID: References: <1145533472.685669.176210@i39g2000cwa.googlegroups.com> Reply-To: "Florian Reiser" X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original To: pgsql-sql@postgresql.org X-Archive-Number: 200604/136 X-Sequence-Number: 24945 Hello Willem, if its not too much data you could do an select * from table an store the result in an array of rows. Then you can iterate over it. If this is too bloated then create a cursor with: declare .... (refer to http://www.postgresql.org/docs/8.1/interactive/sql-declare.html ). Then use fetch to get the desired row. After you are finished use CLOSE to close it. With kind regards Florian Reiser -- http://www.ra-bc.de RA Unternehmensberatung Führen durch präzise Daten "WillemF" schrieb im Newsbeitrag news:1145533472.685669.176210@i39g2000cwa.googlegroups.com... >I am a novice to SQL. Hope my naiivity does not show so clearly. After > consulting the Internet extensively and studying the two thick > reference books that I have, I cannot find an answer to my problem, > which I suspect has no immediate solution. I need to move through a > table and extract the records sequentially one by one and display the > contents on screen. The order of the records is never changed. I can > easily create an index and find a record with an instructuion such as > SELECT * FROM tablename WHILE record_id = 20 , or some similar way. > But if I need to progress to the next record this is an extremely > inefficient way to do it since one has to serach the whole database > just to get to the next record. It would be much easier to have a > pointer to each of the records in the table and use these pointers to > directly jump to the appropriate record. In the old days of DBase there > was an instruction such as GOTO recordnumber. That would set the > pointer to the appropriate record which could then be accessed. With > PgSQL being so much more sophisticated than DBase, I am convinced there > must be an elegant way of solving this problem. Kind regards. >