Search Postgresql Archives

Casting from a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 );' LANGUAGE SQL;
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@xxxxxxxxxxx 
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?"

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux