Casting from a domain

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Casting from a domain
Дата
Msg-id 20050304184935.GG2209@decibel.org
обсуждение исходный текст
Ответы Re: Casting from a domain  (Richard Huxton <dev@archonet.com>)
Re: Casting from a domain  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I'm trying to create a seconds domain that is an interval 'mashed to
seconds' as I once saw Tom describe it.

decibel=# create domain rrs.seconds as double precision;
CREATE DOMAIN
decibel=# create cast (double precision as rrs.seconds) WITHOUT FUNCTION AS IMPLICIT;
CREATE CAST
decibel=# create function rrs.interval_to_seconds(interval) returns seconds as 'SELECT extract( EPOCH FROM $1 );'
LANGUAGESQL; 
CREATE FUNCTION
decibel=# create cast (interval as rrs.seconds) WITH FUNCTION rrs.interval_to_seconds(interval)  AS IMPLICIT;
CREATE CAST
decibel=# select cast('1 month'::interval AS seconds);
ERROR:  cannot cast type interval to seconds

\dC shows that the cast is there, and rrs.interval_to_seconds works as
expected, and according to \df does return seconds.

Version is 7.4.5.
--
Jim C. Nasby, Database Consultant               decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Frankel
Дата:
Сообщение: Re: preserving data after updates
Следующее
От: "Greg Patnude"
Дата:
Сообщение: Re: preserving data after updates