X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 297F0D1B4E1 for ; Tue, 21 Oct 2003 21:40:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56315-08 for ; Tue, 21 Oct 2003 18:39:41 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 83EFCD1B510 for ; Tue, 21 Oct 2003 18:39:39 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C84663526C; Tue, 21 Oct 2003 14:39:26 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C71AC35250; Tue, 21 Oct 2003 14:39:26 -0700 (PDT) Date: Tue, 21 Oct 2003 14:39:26 -0700 (PDT) From: Stephan Szabo To: Josh Berkus Cc: Wilhelm Graiss , "'pgsql-sql@postgresql.org'" Subject: Re: plpgsql related question: intervals and variables In-Reply-To: <200310211143.02533.josh@agliodbs.com> Message-ID: <20031021143506.M52534@megazone.bigpanda.com> References: <40925A3BA1EBD711A35C000102B6E57D06C9A7@BAL_PROXY00> <200310211143.02533.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/280 X-Sequence-Number: 15680 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.