Re: Is there anyway to...

Поиск
Список
Период
Сортировка
От Glen Parker
Тема Re: Is there anyway to...
Дата
Msg-id 454A4B97.9090002@nwlink.com
обсуждение исходный текст
Ответ на Re: Is there anyway to...  (louis gonzales <gonzales@linuxlouis.net>)
Ответы Re: Is there anyway to...  (louis gonzales <gonzales@linuxlouis.net>)
Список pgsql-general
louis gonzales wrote:
> Fine so let's say when the instructor creates the user profile, this can
> trigger the creation of a sequence, say, but IF the instructor doesn't
> visit that student's profile for a month, I want something that,
> independent of any other action, will be either incrementing or
> decrementing that sequence.  So when the instructor does go back to
> visit the student profile it will only show/flag the status if  the time
> has elapsed.  Is there like a sleep() function that postgresql has?
> That could be part of the plan.  So sleep(24hours) - pseudo code - wake
> up and increment something initiate trigger to see if a requirement has
> been met - say 10day or 30day or 1year has elapsed - if so, set a flag
> attribute to the student profile.
>
> During that 30 days, the instructor won't care what's going on behind
> the scenes, they just care when the time has elapsed, that they will get
> a flag, to say, "hey buddy, over here, this student hasn't fulfilled the
> agreement."


I really think you're approaching this wrong by wanting to increment
something every day.  You should generate a query that can run at any
time and determine if any accounts are past due.  You can do the whole
job using some simple date math.  If you do it that way, you could run
the query every time the instructor logs in (not what I would do, but it
would work), and at no other time.

What I would do is run it every evening, say, and send a email
notification to someone (like the instructor) whenever past due accounts
were found.

The problem with your increment design is, what happens if it fails for
some reason?  Maybe the server was down for a memory upgrade, who knows?
  You'll be a day off for every time the job failed to run.

If your logic works even if it skips a few days, as soon as it runs
again, everything will be back up to date.

my .025...

-Glen

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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Is there anyway to...
Следующее
От: Dave Page
Дата:
Сообщение: Re: [SQL] Is there anyway to...