Re: Is there anyway to...

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: louis gonzales <gonzales(at)linuxlouis(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is there anyway to...
Date: 2006-11-08 06:13:36
Message-ID: 20061108061336.GV90133@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-sql

Moving to -general (and please start a new thread instead of hijacking
an existing one).

On Thu, Nov 02, 2006 at 01:14:22PM -0500, 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.

While you could setup a cron job to decrement some counter every day, I
think that's not the best approach. Instead, I'd run a query once a day
that finds all students that are past-due and takes some kind of action.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Jim C. Nasby 2006-11-08 06:17:32 Re: createlang on Mac OS X
Previous Message Michael McCloskey 2006-11-08 01:34:21 Postgres at startup

Browse pgsql-general by date

  From Date Subject
Next Message surabhi.ahuja 2006-11-08 06:59:11 delete performance is extremely slow
Previous Message Gurjeet Singh 2006-11-08 04:55:30 Re: Per-row security

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Frost 2006-11-08 08:23:53 Re: delete and select with IN clause issues
Previous Message Erwin Brandstetter 2006-11-08 00:09:59 Re: Groups and Roles and Users