Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 03BC3B5DC16 for ; Thu, 3 Nov 2011 14:36:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 85733-10 for ; Thu, 3 Nov 2011 17:36:18 +0000 (UTC) X-Greylist: delayed 00:06:25.113678 by SQLgrey-1.8.0-rc2 Received: from smtp.comsquared.com (smtp.comsquared.com [209.155.237.140]) by mail.postgresql.org (Postfix) with ESMTP id 43A96B5DBC8 for ; Thu, 3 Nov 2011 14:36:17 -0300 (ADT) Received: from mdpserv.comsquared.com (mdpserv [10.82.40.1]) by smtp.comsquared.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id pA3HTggb003078 for ; Thu, 3 Nov 2011 13:29:45 -0400 (EDT) Received: from erouse052008 ([10.82.60.61]) by mdpserv.comsquared.com (8.13.6+Sun/8.13.6) with ESMTP id pA3HTgKI027653 for ; Thu, 3 Nov 2011 13:29:42 -0400 (EDT) From: "Edward W. Rouse" To: Subject: intervals Date: Thu, 3 Nov 2011 13:29:40 -0400 Message-ID: <00ee01cc9a4e$2b41f050$81c5d0f0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcyaTir/3QcZJtJJS/CV72EP/KcQ6g== Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/5 X-Sequence-Number: 35978 I am writing a procedure and am having a little difficulty with an interval. In the DECLARE section I have: expire interval := '30 days'::interval; which seems to work fine. In the BEGIN block I need to pull out the number of days from a table and update the expire interval to that. But I can't quite seem to get the replacement correct. First I use "SELECT value into limit from" to get the new limit value. The value is text, but I have also tried with SELECT (value::integer) into limit from" with the same result. The error occurs here: expire := '% days'::interval, limit; Now I have tried several different ways to get a new interval, such as '' || limit || days''::interval; and other various differently quoted variations, but haven't found the one that works yet. I am still trying various combinations, but thought that someone on the list has probably done this already. I may, in fact, be doing it entirely wrong. So if someone knows the correct/better/easier way to create a dynamic interval I'd appreciate a clue. Thanks. Edward W. Rouse