| From: | Tod McQuillin <devin(at)spamcop(dot)net> |
|---|---|
| To: | Janning Vygen <vygen(at)planwerk6(dot)de> |
| Cc: | Len Morgan <len-morgan(at)crcom(dot)net>, PostgreSQL-General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: newbie sql question: select every day another quote |
| Date: | 2001-05-12 13:30:00 |
| Message-ID: | Pine.GSO.4.31.0105120826360.1166-100000@sysadmin |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Sat, 12 May 2001, Janning Vygen wrote:
> Am Samstag, 12. Mai 2001 14:37 schrieb Len Morgan:
> > The "no result part" is harder. You'll have to have some sort of client
> > program that can tell you if the above quote returned a row or not. Once
> > you have that, if the above query did NOT return a row, you can use the
> > following two steps:
> >
> > UPDATE quotes SET lastdayshown = now():: WHERE oid = (SELECT oid FROM
> > quotes WHERE lastdayshown IS NULL LIMIT 1) ;
>
> i managed this now in php. works fine
> but the idea was to put this structure into the database, so the db user just
> have to send one select and once a day there is an automagical update.
It will probably work to make a plpgsql function doing something like:
1. Figure out the primary key of today's quote
2. Update the database if necessary
3. Return the key of today's quote
then you can SELECT * from quotes WHERE key = todays_key();
--
Tod McQuillin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | will trillich | 2001-05-12 14:32:51 | Re: simple rule question |
| Previous Message | Janning Vygen | 2001-05-12 13:01:49 | Re: newbie sql question: select every day another quote |