Re: intervals

From: "Edward W(dot) Rouse" <erouse(at)comsquared(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: intervals
Date: 2011-11-03 17:56:09
Message-ID: 00f501cc9a51$de2c1080$9a843180$@com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

That was part of the problem. Thanks for the info.

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-
> owner(at)postgresql(dot)org] On Behalf Of Jonathan S. Katz
> Sent: Thursday, November 03, 2011 1:41 PM
> To: Edward W. Rouse
> Cc: pgsql-sql(at)postgresql(dot)org
> Subject: Re: [SQL] intervals
>
> 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:
> >
> > 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
> >
> >
> >
> >
> > --
> > Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-sql
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Edward W. Rouse 2011-11-03 17:59:08 Re: intervals
Previous Message bricklen 2011-11-03 17:43:39 Re: intervals