pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Glen Parker <glenebob@nwlink.com>
To: pgsql-general@postgresql.org
Subject: Re: Is there anyway to...
Date: Thu, 02 Nov 2006 11:48:39 -0800
Message-ID: <454A4B97.9090002@nwlink.com> (raw)
In-Reply-To: <454A45E4.8090409@linuxlouis.net>
References: <20061102171624.GE21312@localhost>
	<454A357E.6010409@linuxlouis.net>
	<454A394C.7020102@zijn-digital.com>
	<454A3EB6.8080806@linuxlouis.net>
	<20061102190906.GA23069@KanotixBox>
	<454A45E4.8090409@linuxlouis.net>

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



view thread (29+ messages)  latest in thread

Message-ID: <454A4B97.9090002@nwlink.com>
Permalink:  ../454A4B97.9090002@nwlink.com/
Also on:    postgresql.org/message-id/454A4B97.9090002@nwlink.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: glenebob@nwlink.com, pgsql-general@postgresql.org
  Subject: Re: Is there anyway to...
  In-Reply-To: <454A4B97.9090002@nwlink.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox