Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 532C29FB21E for ; Thu, 2 Nov 2006 15:48:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 54248-01-2 for ; Thu, 2 Nov 2006 19:48:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from inetserver.servicepaper.com (67.105.202.226.ptr.us.xo.net [67.105.202.226]) by postgresql.org (Postfix) with ESMTP id AB2879FB2EE for ; Thu, 2 Nov 2006 15:48:40 -0400 (AST) Received: from [192.168.10.100] ([192.168.10.100]) by inetserver.servicepaper.com (8.11.6/8.11.6) with ESMTP id kA2JmdE13544 for ; Thu, 2 Nov 2006 11:48:39 -0800 Message-ID: <454A4B97.9090002@nwlink.com> Date: Thu, 02 Nov 2006 11:48:39 -0800 From: Glen Parker User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: Is there anyway to... References: <20061102171624.GE21312@localhost> <454A357E.6010409@linuxlouis.net> <454A394C.7020102@zijn-digital.com> <454A3EB6.8080806@linuxlouis.net> <20061102190906.GA23069@KanotixBox> <454A45E4.8090409@linuxlouis.net> In-Reply-To: <454A45E4.8090409@linuxlouis.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.779 tagged_above=0 required=5 tests=BAYES_20, FORGED_RCVD_HELO, SPF_SOFTFAIL X-Spam-Level: X-Archive-Number: 200611/118 X-Sequence-Number: 103214 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