Re: plpgsql related question: intervals and variables - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: plpgsql related question: intervals and variables
Date
Msg-id 20031021143506.M52534@megazone.bigpanda.com
Whole thread Raw
In response to Re: plpgsql related question: intervals and variables  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
On Tue, 21 Oct 2003, Josh Berkus wrote:

> >    heute := ''today'';
> > Select Into vk ourcolumn From table where other = foo;
> >    If vk > 0 Then
> >     vk_txt := ''Vorkuehlung notwendig'';
> >     ez  := heute + interval ''vk days'';
>
> PL/pgSQL handles variable like SQL, not like PHP or Perl.  You can't do a
> variable substitution inside quotes, and you need to cast:
>
> ez  := heute + interval (cast(vk as text) ||  '' days'');

I think that something likeez := heute + vk * interval '1 day';
might be better in general.



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: function problem
Next
From: Abdul Wahab Dahalan
Date:
Subject: Timestamp