Re: case when evaluating else condition anyway?

Поиск
Список
Период
Сортировка
Искать
От
Sam Mason
Тема
Re: case when evaluating else condition anyway?
Дата
Msg-id
20081126152544.GA2459@frubble.xen.chris-lamb.co.uk
Ответ на
Список
Дерево обсуждения
case when evaluating else condition anyway? Ivan Sergio Borgonovo <mail@webthatworks.it>
Re: case when evaluating else condition anyway? Sam Mason <sam@samason.me.uk>
Re: case when evaluating else condition anyway? Ivan Sergio Borgonovo <mail@webthatworks.it>
Re: case when evaluating else condition anyway? Sam Mason <sam@samason.me.uk>
Re: case when evaluating else condition anyway? Tom Lane <tgl@sss.pgh.pa.us>
Re: case when evaluating else condition anyway? Tom Lane <tgl@sss.pgh.pa.us>
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
В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
От: Tom Lane
Дата:
FAQ