View

Поиск
Список
Период
Сортировка
От A Gilmore
Тема View
Дата
Msg-id 4335A4CD.0@shaw.ca
обсуждение исходный текст
Ответы Re: View
Список pgsql-novice
Hello,

I have dates in a database that look something like so :
CREATE TABLE myEvents (
    id            integer DEFAULT nextval('serial_seq') PRIMARY KEY,
    cal_id        integer not null
                    references saa_calendars(id)
                    on update cascade on delete cascade,
    start_date    timestamp with time zone NOT NULL DEFAULT now(),
    end_date    timestamp with time zone NOT NULL DEFAULT now() + interval '1
hour',
    summary        text NOT NULL DEFAULT '',
    description    text NOT NULL DEFAULT ''
    );

CREATE TABLE myRecurrence (
    id            integer DEFAULT nextval('serial_seq') PRIMARY KEY,
    event_id    integer not null
                    references myEvents(id)
                    on update cascade on delete cascade,
    timeInterval integer not null default '1', -- Number of
weeks/days/months etc
    timeSpan    text NOT NULL DEFAULT 'day', -- day,week,month etc
    limitDate    timestamp with time zone NOT NULL DEFAULT now()
    );

So I have event bookings, then if they use some kind of recurrence, its
stored in myRecurrence.  This has worked fine, since sorting out
recurring dates (creating the duplicate events) is all done client-side
based on these entries.

However now I need the server to be aware of recurring dates.  So if an
event is booked, then to recur each month for 5 months, Id have 5
entires show up in my SELECT.  I was hoping to wrap this up in a VIEW
however Im at a loss as to how to do it, since its not your typical JOIN
or anything.

Is this possible in a regular VIEW or am I going to need to create a
plpgsql function or some other procedural method of accomplishing this?

Thank you for your time,
- A Gilmore

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Announce"
Дата:
Сообщение: Re: Primary and Foreign Key?
Следующее
От: Rafael Barbosa
Дата:
Сообщение: Windows XP + Postgre