Search Postgresql Archives

Re: Is there anyway to...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux