How to get "next" record in a recordset

From: "Peter Alberer" <h9351252(at)obelix(dot)wu-wien(dot)ac(dot)at>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to get "next" record in a recordset
Date: 2002-09-10 08:26:53
Message-ID: 000301c258a3$d1985490$5be0d089@ekelhardt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am developing a testing application for the web where students can
navigate thru multiple choice quizzes. Of course there should be a
button to go to the next question (by alphabet, random, categories) My
problem is how to get the “next” question of a certain recordset. For
example:

select
lro.lr_object_id, lro.lr_title
from lr_objects lro, acs_rels
where object_id_one = '10524'
and rel_type= 'lr_concept_rel'
and object_id_two = lro.lr_object_id
and lro.is_active='t'
and restype = 'excs'
order by lro.lr_title;

lr_object_id | lr_title
--------------+--------------------------------------------
14617 | Übungsaufgabe 2-31
14614 | Übungsaufgabe 2-32
13226 | Attacken von Free-Software-Programmen
13297 | Aussagen über Computerviren
13300 | Aussagen über Computerviren
13311 | Aussagen über Makros
13316 | Aussagen über Virusprogramme
13235 | Aussagen im Zusammenhang mit Computerviren
13400 | Computerviren
13742 | Maßnahmen zum Schutz vor Computerviren
13768 | Mögliche Fälle von Computerviren
13774 | Möglichkeit eines Virenbefalls
13809 | PC-Programm: &quot;Swiss Phönix&quot;
13850 | Regelmäßige Virenüberprüfung
14071 | Warnung im Computermagazin

I can not order by lr_object_id. If the lr_object_id of the current
question is 13742 how can I retrieve the next lr_object_id with one
sql-query? I have created a function (plpgsql) to get the next id but
can it be done an easier way?

TIA, peter alberer

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2002-09-10 08:46:52 Re: How to get "next" record in a recordset
Previous Message Karel Zak 2002-09-10 07:40:07 Re: Psql regex is NFA or DFA?