pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: louis gonzales <gonzales@linuxlouis.net>
To: brian <brian@zijn-digital.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Is there anyway to...
Date: Thu, 02 Nov 2006 13:53:42 -0500
Message-ID: <454A3EB6.8080806@linuxlouis.net> (raw)
In-Reply-To: <454A394C.7020102@zijn-digital.com>
References: <20061102171624.GE21312@localhost>
	<454A357E.6010409@linuxlouis.net>
	<454A394C.7020102@zijn-digital.com>

Hey Brian,
Yeah I had considered this, using cron, I just feel like that is too dirty.

Actually I didn't see Andreas' post, can someone forward that?

I'm running this application on Solaris 9.  Ultimately what I want to 
know is, is there something that is internal to postgresql that can be 
used that doesn't need external action, to make it do some task?

Some built in function that can be set to do some simple task on a daily 
- or other time - interval, where all of the defined users may not have 
any activity with the database for day's or week's at a time, but this 
builtin function still operates?

Am I making any sense with how I'm asking this?  I could of course have 
cron do a scheduled task of checking/incrementing/decrementing and 
define triggers to occur when one of the cron delivered actions sets the 
appropriate trigger off, but are there other methods that are standard 
in the industry or are we stuck with this type of external influence?

Thanks all!

brian wrote:

> louis gonzales wrote:
>
>> Hello all,
>> Is there an existing mechanism is postgresql that can automatically 
>> increment/decrement on a daily basis w/out user interaction?  The use 
>> case I'm considering is where a student is in some type of contract 
>> with an instructor of some sort, and that contract puts a time limit 
>> on the student requiring her to pay a fee by a certain day.  IF that 
>> day comes to pass - or a certain number of days elapse - and that 
>> payment requirement hasn't been met, I want to trigger a function.
>>
>> The one requirement I want to impose is, that no end user of the DB 
>> application, needs to do anything to set the trigger, other than the 
>> initialization of making the student of this type.
>>
>> An example would be:
>> Day1 - Application user(typically the instructor) creates a profile 
>> for a new student - John Doe, which sets a 30 day time limit for John 
>> Doe to pay $100.00
>> Day2 -> Day31 - John Doe didn't make the payment
>> Day 31 - Trigger of event occurs when the instructor logs in.
>>
>> Basically on Day 1 when John Doe's profile was created, I want a 
>> decrement counter to occur daily on his profile(some attribute/timer) 
>> and nothing should happen until day 31 when he doesn't pay.
>>
>
> Further to Andreas' suggestion to use CRON, you don't require a 
> decrement of anything. When the profile is created, your date_created 
> (or whatever) column will be set. Then your script (called by CRON) 
> only needs to test for rows that a) have not paid, and b) are outside 
> the bounds set in the script (eg. MAX_GRACE_PERIOD = 30).
>
> brian
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org/



-- 
Email:    louis.gonzales@linuxlouis.net
WebSite:  http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka




view thread (29+ messages)  latest in thread

Message-ID: <454A3EB6.8080806@linuxlouis.net>
Permalink:  ../454A3EB6.8080806@linuxlouis.net/
Also on:    postgresql.org/message-id/454A3EB6.8080806@linuxlouis.net

 · 

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: gonzales@linuxlouis.net, brian@zijn-digital.com, pgsql-general@postgresql.org
  Subject: Re: Is there anyway to...
  In-Reply-To: <454A3EB6.8080806@linuxlouis.net>

* 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