Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 887269FB251 for ; Thu, 9 Nov 2006 06:17:46 -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 85393-09 for ; Thu, 9 Nov 2006 10:17:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 845E59FB24B for ; Thu, 9 Nov 2006 06:17:43 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 5F5317482F; Thu, 9 Nov 2006 10:17:42 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 2AE3615EAB; Thu, 9 Nov 2006 10:17:42 +0000 (GMT) Message-ID: <455300C3.4050008@archonet.com> Date: Thu, 09 Nov 2006 10:19:47 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5.0.7 (X11/20060918) MIME-Version: 1.0 To: operationsengineer1@yahoo.com Cc: "pgsql-general@postgresql.org" Subject: Re: [SQL] [ADMIN] Is there anyway to... References: <20061109012417.34765.qmail@web33310.mail.mud.yahoo.com> In-Reply-To: <20061109012417.34765.qmail@web33310.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/491 X-Sequence-Number: 103587 operationsengineer1@yahoo.com wrote: > i'm wanting to learn something here so i'm going to > chime in. > > the way i read what you are saying is that you'd have > start_date and number_days columns in your table. > > each day a query would run and pull the start_date and > numbers_days columns. > > the application (or postgresql function) would then > take the current date, subtract starte date and > compare it to number of days. if it is above that > number, the code will take some sort of action. > > is that about it or have i missed something? I think that's what Jim's talking about. Databases are good at filtering large numbers of rows. You'll also want some sort of status code or "processed" flag, so you know not to look at rows you've already handled. The other alternative would be an "expiry_list" table that stores the target row's key and when it expires. Add a row when the contract is created. Delete the row when the contract is paid. Keep it all up-to-date with triggers. -- Richard Huxton Archonet Ltd