Re: Casting varchar to interval.?

Поиск
Список
Период
Сортировка
Искать
От
Jim Wilson
Тема
Re: Casting varchar to interval.?
Дата
Msg-id
twig.1075128218.74761@kelcomaine.com
Ответ на
Список
Дерево обсуждения
Casting varchar to interval.? "D. Dante Lorenso" <dante@lorenso.com>
Re: Casting varchar to interval.? "Jim Wilson" <jimw@kelcomaine.com>
Re: Casting varchar to interval.? Richard Huxton <dev@archonet.com>
Re: Casting varchar to interval.? Tom Lane <tgl@sss.pgh.pa.us>
Is this a bug?  You can work around it by wrapping the varying in a trim()
function (e.g. select trim(config_value)::interval from config).  I've solved
another suspicious looking issue with that same kind of workaround.

Best regards,

Jim Wilson


"D. Dante Lorenso"  said:

> I was hoping to cast a varchar to an interval.
> How is this done?  Nobody has provided an answer to
> this questing when asked in the past:
> 
>     http://archives.postgresql.org/pgsql-general/2002-07/msg01482.php
>    
> I have a table 'config' that contains:
> 
>     CREATE TABLE "public"."config" (
>       "config_key" VARCHAR(64) NOT NULL,
>       "config_value" VARCHAR(256) NOT NULL,
>       PRIMARY KEY("config_key")
>     ) WITH OIDS;
> 
> So I can do this:
> 
>     # SELECT config_value
>     # FROM config
>     # WHERE config_key = 'commission_withhold_interval';
>      config_value
>     --------------
>      1 month
>     (1 row)
> 
> But I can't do this:
> 
>     # SELECT config_value::interval
>     # FROM config
>     # WHERE config_key = 'commission_withhold_interval';
>    
>     ERROR:  cannot cast type character varying to interval
> 
> Why doesn't that work?

В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
Сообщение: Re: FAQ (disk space)
От: Jeff Eckermann
Дата:
FAQ