栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

达梦数据库-兼容Oracle sys

达梦数据库-兼容Oracle sys

如何将一个时区的本地时间,转换为另一个时区的本地时间?
达梦没有做oracle sys_extract_utc函数的兼容,那么我们可以自己写个函数来实现兼容

CREATE or REPLACe
        FUNCTION sys_extract_utc FOR CALCULATE
                (
                        v_time in datetime
                        (
                                6)
                with time zone)
                RETURN timestamp
        is
        begin
                return
                case substr(v_time, 28, 1)--通过正负号来判定东西时区
                when '+' then--截取本地时区,并转换为utc时间
                        to_date(substr(v_time, 0, 27))-to_number(substr(v_time, 29, 2))/24-to_number(substr(v_time, 32, 2))/24/60
                when '-' then
                        to_date(substr(v_time, 0, 27))+to_number(substr(v_time, 29, 2))/24+to_number(substr(v_time, 32, 2))/24/60
                end;
        end;

效果演示

还可以通过该函数实现做列的默认值

crEATE
        TABLE "TEST"."T_TIMEZONE"
        (
                "C1" TIMESTAMP(3)
WITH
        LOCAL TIME ZONE,
        "C2" TIMESTAMP(3) default sys_extract_utc(systimestamp)
        ) ;
insert into T_TIMEZONE
        (c1
        ) values
        (systimestamp
        );
select * from T_TIMEZONE

更多资讯请上达梦技术社区了解: https://eco.dameng.com

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/285729.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号