PostgreSQL创建cast一个例子

Posted on 2013-03-01 10:59  JasmineLiu  阅读(1904)  评论(0编辑  收藏  举报

CREATE OR REPLACE FUNCTION _time_to_integer(time with time zone)
RETURNS integer AS $$
SELECT
EXTRACT(HOUR FROM $1)::integer * 10000
+ EXTRACT(MINUTE FROM $1)::integer * 100
+ EXTRACT(SECONDS FROM $1)::integer
$$ IMMUTABLE STRICT LANGUAGE SQL;


DROP CAST IF EXISTS (time with time zone AS integer);


CREATE CAST (time with time zone AS integer)
WITH FUNCTION _time_to_integer (time with time zone)
AS IMPLICIT;

Copyright © 2024 JasmineLiu
Powered by .NET 9.0 on Kubernetes