From: | "Florian Reiser" <florian(dot)reiser(at)ra-bc(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Moving around in a SQL database |
Date: | 2006-04-20 12:35:24 |
Message-ID: | e27v66$2jvn$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
Fhren durch przise Daten
"WillemF" <jwhferguson(at)zoology(dot)up(dot)ac(dot)za> schrieb im Newsbeitrag
news:1145533472(dot)685669(dot)176210(at)i39g2000cwa(dot)googlegroups(dot)com(dot)(dot)(dot)
>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.
>
From | Date | Subject | |
---|---|---|---|
Next Message | John Goss | 2006-04-20 13:31:20 | At time zone madness! |
Previous Message | Christian Paul B. Cosinas | 2006-04-20 11:42:24 | Programatically Backup Database Using Visual Basic |