newbie sql question: select every day another quote

From: Janning Vygen <vygen(at)planwerk6(dot)de>
To: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: newbie sql question: select every day another quote
Date: 2001-05-12 08:55:57
Message-ID: 01051210555700.29826@janning
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

for tutoral purpose i ve build a quotes table like this:

create table quotes (name text, quote text, lastdayshown date UNIQUE);
insert into quotes (name, quote) values ('caesar', 'veni vidi vici');
insert into quotes (name, quote) values ('hamlet', 'to be or not to be');

lastdayshown is always null on insert.
works fine. Now i want to select every day a different quote.

Is it possible to
select the row with lastdayshown = today
if no result
update one row with lastdayshown = null
else
update one row with oldest lastdayshown.

I want to put this procedural structure into sql, maybe creating a view, in
which the database user always sees the "Quote of the Day".

Maybe i am still thinking in procedural structures. Do i have to use PL/SQL
for it?

thanks in advance
janning

--
Planwerk 6 /websolutions
Herzogstraße 86
40215 Düsseldorf

fon 0211-6015919
fax 0211-6015917
http://www.planwerk6.de

Browse pgsql-general by date

  From Date Subject
Next Message Simon Crute 2001-05-12 10:23:10 case sensitivity
Previous Message Andrew Snow 2001-05-12 06:14:33 RE: simple rule question