pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: Wilhelm Graiss <Wilhelm.Graiss@bal.bmlfuw.gv.at>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: plpgsql related question: intervals and variables
Date: Tue, 21 Oct 2003 14:39:26 -0700 (PDT)
Message-ID: <20031021143506.M52534@megazone.bigpanda.com> (raw)
In-Reply-To: <200310211143.02533.josh@agliodbs.com>
References: <40925A3BA1EBD711A35C000102B6E57D06C9A7@BAL_PROXY00>
	<200310211143.02533.josh@agliodbs.com>

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 like
 ez := heute + vk * interval '1 day';
might be better in general.




view thread (4+ messages)

Message-ID: <20031021143506.M52534@megazone.bigpanda.com>
Permalink:  ../20031021143506.M52534@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20031021143506.M52534@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, josh@agliodbs.com, Wilhelm.Graiss@bal.bmlfuw.gv.at
  Subject: Re: plpgsql related question: intervals and variables
  In-Reply-To: <20031021143506.M52534@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox