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

Re: case when evaluating else condition anyway?

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: case when evaluating else condition anyway?
Date: 2008-11-26 15:25:44
Message-ID: 20081126152544.GA2459@frubble.xen.chris-lamb.co.uk (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, Nov 26, 2008 at 04:17:40PM +0100, Ivan Sergio Borgonovo wrote:
> as a more self contained example:
> 
> select case when ''='' then null else ''::timestamp end;

Tee hee, I've just realized what you're doing.  You've got the cast in
the wrong place!  Try:

  select case when ''='' then null else '' end::timestamp;

I was reading it this way around automatically!  Literals are always
expanded immediately and hence you're getting the error.  You want the
case statement to work with strings and only cast it when you know it's
actually safe to make the move from a string literal to a timestamp
value.


  Sam

In response to

pgsql-general by date

Next:From: Tom LaneDate: 2008-11-26 15:29:10
Subject: Re: case when evaluating else condition anyway?
Previous:From: Tom LaneDate: 2008-11-26 15:20:49
Subject: Re: Problem with langage encoding

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