From: Florian Reiser <florian.reiser@ra-bc.de>
To: pgsql-sql@postgresql.org
Subject: Re: Moving around in a SQL database
Date: Thu, 20 Apr 2006 14:35:24 +0200
Message-ID: <e27v66$2jvn$1@news.hub.org> (raw)
References: <1145533472.685669.176210@i39g2000cwa.googlegroups.com>
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 <cursorname> .... (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" <jwhferguson@zoology.up.ac.za> 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.
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: florian.reiser@ra-bc.de
Subject: Re: Moving around in a SQL database
In-Reply-To: <e27v66$2jvn$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox