Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7B089B5DC30 for ; Thu, 3 Nov 2011 14:47:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 02960-06 for ; Thu, 3 Nov 2011 17:47:37 +0000 (UTC) X-Greylist: delayed 00:06:12.361235 by SQLgrey-1.8.0-rc2 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id CBC72B5DBC8 for ; Thu, 3 Nov 2011 14:47:36 -0300 (ADT) Received: by vws1 with SMTP id 1so1132314vws.19 for ; Thu, 03 Nov 2011 10:47:36 -0700 (PDT) Received: by 10.52.33.69 with SMTP id p5mr10615879vdi.78.1320342081340; Thu, 03 Nov 2011 10:41:21 -0700 (PDT) Received: from [192.168.1.122] (rrcs-184-75-23-182.nyc.biz.rr.com. [184.75.23.182]) by mx.google.com with ESMTPS id il5sm8779890vdb.7.2011.11.03.10.41.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Nov 2011 10:41:20 -0700 (PDT) Subject: Re: intervals Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Jonathan S. Katz" In-Reply-To: <00ee01cc9a4e$2b41f050$81c5d0f0$@com> Date: Thu, 3 Nov 2011 13:41:16 -0400 Cc: Content-Transfer-Encoding: quoted-printable Message-Id: References: <00ee01cc9a4e$2b41f050$81c5d0f0$@com> To: "Edward W. Rouse" X-Mailer: Apple Mail (2.1084) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/7 X-Sequence-Number: 35980 Hi Edward, "LIMIT" is a keyword, which is where you are getting your errors. Did = you try a different variable name? Best, Jonathan On Nov 3, 2011, at 1:29 PM, Edward W. Rouse wrote: > I am writing a procedure and am having a little difficulty with an = interval. > In the DECLARE section I have: >=20 > expire interval :=3D '30 days'::interval; >=20 > 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. >=20 > 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: >=20 > expire :=3D '% days'::interval, limit; >=20 > 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. >=20 > Thanks. >=20 >=20 > Edward W. Rouse >=20 >=20 >=20 >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql