Skip site navigation (1) Skip section navigation (2)

Re: Interval constant syntax, was Re: Interval & check clause

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Bruno BAGUETTE <pgsql-ml(at)baguette(dot)net>,pgsql-general(at)postgresql(dot)org
Subject: Re: Interval constant syntax, was Re: Interval & check clause
Date: 2004-03-29 21:28:59
Message-ID: 20040329152859.M9609@mofo.meme.com (view raw or flat)
Thread:
Lists: pgsql-general
On 2004.03.29 14:44 Bruno Wolff III wrote:
> 
> In postgres you shouldn't have to explicitly cast the constant to an
> interval as long as there isn't one than one >= operator that could
> be applied (depending on the eventaul type of the constant). I would
> really be surprized if this were to happen for >= and an interval
> operand
> on one side or the other.
> 
> It won't work with two unknown constants, if that was what you tested.
> Try just casting on one side.

This is my plpgsql code

  PERFORM MATUREDATES.sname FROM MATUREDATES
     WHERE NEW.sname = MATUREDATES.sname
           AND ( NEW.birth > MATUREDATES.Matured - ''3 years''
                 OR NEW.birth > MATUREDATES.Matured - ''7 years'');
   IF FOUND THEN

And this was my scratch psql test:

=> select CAST('1/1/2004' AS date) - '3 years';
ERROR:  Bad date external representation '3 years'

I am using 7.3 so maybe this has been fixed.  Or it's just the
operator, some require casts and some don't and you just have to find
out the hard way.  :(

Karl <kop(at)meme(dot)com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

In response to

Responses

pgsql-general by date

Next:From: Mike NolanDate: 2004-03-29 21:32:29
Subject: Re: PG vs MySQL
Previous:From: scott.marloweDate: 2004-03-29 21:22:20
Subject: Re: PG vs MySQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group