国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

南大通用數(shù)據(jù)庫(Gbase 8s) 創(chuàng)建UDR外部函數(shù)

這篇具有很好參考價(jià)值的文章主要介紹了南大通用數(shù)據(jù)庫(Gbase 8s) 創(chuàng)建UDR外部函數(shù)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、在使用 date_format、from_unixtime、to_days、yearweek 函數(shù)時(shí),Gbase 8s 數(shù)據(jù)庫不支持,可以使用創(chuàng)建 UDR 外部函數(shù)來實(shí)現(xiàn)

二、登錄命令控制臺(tái)或者使用 navicat 連接 Gbase 數(shù)據(jù)庫

這里使用 navicat ,點(diǎn)擊新增連接選擇 PostGreSql 驅(qū)動(dòng),添加地址、賬號(hào)、密碼
連接數(shù)據(jù)庫后,選中目標(biāo)庫選中目標(biāo)模式,再點(diǎn)擊函數(shù)-新增函數(shù)執(zhí)行以下語句即可

注意:這里 選中 public 模式,使用 mss 用戶,自行修改函數(shù)中對(duì)應(yīng)的內(nèi)容( 例如:FUNCTION “public”.“date_format”、OWNER TO “mss”)

  1. date_format 函數(shù)

    CREATE OR REPLACE FUNCTION "public"."date_format"("ctimestamp" timestamptz, "informate" varchar)
     RETURNS "pg_catalog"."varchar" AS $BODY$
       -- Routine body goes here...
     DECLARE  
           result_current_date varchar;
       BEGIN
    --             IF upper($1) = upper('YYYY-MM-DD') || upper($1) = upper('%Y-%M-%D') THEN
    --                     SELECT to_char(now(),'YYYY-MM-DD') into result_current_date;
    --             END IF;
    --     
    --             
    --             IF upper($1) = upper('%Y-%M-%D %h:%m') || upper($1) = upper('%Y-%M-%D %h:%m') THEN
    --                     SELECT to_char(now(),'YYYY-MM-DD HH:mm') into result_current_date;
    --             END IF;
    --             
    --           IF upper($1) = upper('%Y-%M-%D %h:%m:%s') || upper($1) = upper('%Y-%M-%D %h:%m:%s') THEN
    --                     SELECT to_char(now(),'YYYY-MM-DD HH:mm:ss') into result_current_date;
    --             END IF;
               
               case upper($2)
                   when upper('%Y') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY') into result_current_date;
                   when upper('%Y-%M') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY-MM') into result_current_date;                    
                   when upper('%Y-%M-%D') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY-MM-DD') into result_current_date;
                   when upper('%Y-%M-%D %h') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY-MM-DD HH24') into result_current_date;
                   when upper('%Y-%M-%D %h:%m') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY-MM-DD HH24:MI') into result_current_date;
                   when upper('%Y-%M-%D %h:%m:%s') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'YYYY-MM-DD HH24:MI:ss') into result_current_date;            
                   when upper('%M') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'MM') into result_current_date;                
                   when upper('%M-%D') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'MM-DD') into result_current_date;
                   when upper('%D') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'DD') into result_current_date;
                   when upper('%h') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'HH24') into result_current_date;    
                   when upper('%h:%m') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'HH24:MI') into result_current_date;            
                   when upper('%m') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'MI') into result_current_date;                            
                   when upper('%m:%s') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'MI:ss') into result_current_date;        
                   when upper('%s') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'ss') into result_current_date;                                                                
                   when upper('%h:%m:%s') then
                       SELECT to_char(smalldatetime_to_timestamp($1),'HH24:MI:ss') into result_current_date;            
                                                   
                   else
                       SELECT to_char(smalldatetime_to_timestamp($1),informate) into result_current_date;
               end case;
               
           RETURN result_current_date;
    END$BODY$
     LANGUAGE plpgsql VOLATILE
     COST 100;
    
    ALTER FUNCTION "public"."date_format"("ctimestamp" timestamptz, "informate" varchar) OWNER TO "mss";
    

    查詢語句:

    SELECT date_format(now(),'%Y-%M-%D %h:%m:%s');
    
  2. from_unixtime 函數(shù)

    CREATE OR REPLACE FUNCTION "public"."from_unixtime"("t" int8)
      RETURNS "pg_catalog"."timestamp" AS $BODY$
      DECLARE  
            result_current_date timestamp;
      BEGIN  
         select TO_TIMESTAMP(t) into result_current_date;
        RETURN result_current_date;
    END; $BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
      
    ALTER FUNCTION "public"."from_unixtime"("t" int8) OWNER TO "mss";
    

    查詢語句:

    select from_unixtime(1692328679);
    
  3. to_days 函數(shù)

    -- 參數(shù) varchar類型
    CREATE OR REPLACE FUNCTION "public"."to_days"("ctimestamp" varchar)
      RETURNS "pg_catalog"."int4" AS $BODY$
        -- Routine body goes here...
      DECLARE  
            result_current_date int4;
        BEGIN
                SELECT TIMESTAMPDIFF(day, '0001-01-01', $1) into result_current_date;
            RETURN result_current_date;
    END$BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
    
    
    ALTER FUNCTION "public"."to_days"("ctimestamp" varchar) OWNER TO "mss";
    
    -- 參數(shù) timestamptz 類型
    CREATE OR REPLACE FUNCTION "public"."to_days"("ctimestamp" timestamptz)
      RETURNS "pg_catalog"."int4" AS $BODY$
        -- Routine body goes here...
      DECLARE  
            result_current_date int4;
        BEGIN
                SELECT TIMESTAMPDIFF(day, '0001-01-01', $1) into result_current_date;
            RETURN result_current_date;
    END$BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
    
    
    ALTER FUNCTION "public"."to_days"("ctimestamp" timestamptz) OWNER TO "mss";
    

    查詢語句:

    select to_days(now());
    
  4. yearweek 函數(shù)

    CREATE OR REPLACE FUNCTION "public"."yearweek"("ctimestamp" timestamptz)
      RETURNS "pg_catalog"."int4" AS $BODY$
        -- Routine body goes here...
      DECLARE  
            week_n int4;
            year_n int4;
        BEGIN
                SELECT to_char(smalldatetime_to_timestamp($1),'YYYY') into year_n;
                SELECT trunc(1 + (smalldatetime_to_timestamp($1) - TRUNC(smalldatetime_to_timestamp($1), 'YEAR')) / 7) into week_n;
            RETURN ((year_n*100)+week_n);
    END$BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
    
    
    ALTER FUNCTION "public"."yearweek"("ctimestamp" timestamptz) OWNER TO "mss";
    

    查詢語句:文章來源地址http://www.zghlxwxcb.cn/news/detail-662181.html

    select YEARWEEK(now());
    select YEARWEEK('2023-01-03 12');
    

到了這里,關(guān)于南大通用數(shù)據(jù)庫(Gbase 8s) 創(chuàng)建UDR外部函數(shù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 面向海量異構(gòu)數(shù)據(jù)分析的GBASE南大通用數(shù)據(jù)庫

    GBaseBI V5是GBASE南大通用公司面向海量異構(gòu)數(shù)據(jù)分析,以獨(dú)特的語義映射和內(nèi)存計(jì)算為基礎(chǔ),以“可視化”展示為重點(diǎn)的一款高性能數(shù)據(jù)分析平臺(tái);具備滿足企事業(yè)單位對(duì)KPI指標(biāo)監(jiān)控、數(shù)據(jù)預(yù)測、數(shù)據(jù)預(yù)警、數(shù)據(jù)匯總和數(shù)據(jù)可視化展示等需求的能力。 GBaseBI V5整體采用B/S構(gòu)架,

    2024年01月19日
    瀏覽(21)
  • GBASE南大通用分析型MPP數(shù)據(jù)庫GBase8a的安全特性(2)

    GBase南大通用自主研發(fā)的 GBase 8a MPP Cluster 產(chǎn)品(簡稱GBase8a)是大數(shù)據(jù)時(shí)代成熟的分析型MPP數(shù)據(jù)庫,具有多樣化的平臺(tái)選擇、與時(shí)俱進(jìn)的邏輯架構(gòu)、海量數(shù)據(jù)高效存儲(chǔ)、海量數(shù)據(jù)高速加載、海量數(shù)據(jù)高性能分析、彈性服務(wù)器資源伸縮、完善的系統(tǒng)資源管理、多級(jí)別的高可用、跨

    2024年01月25日
    瀏覽(17)
  • GBASE南大通用分析型MPP數(shù)據(jù)庫GBase8a的安全特性(1)

    GBase南大通用自主研發(fā)的 GBase 8a MPP Cluster 產(chǎn)品(簡稱GBase8a)是大數(shù)據(jù)時(shí)代成熟的分析型MPP數(shù)據(jù)庫,具有多樣化的平臺(tái)選擇、與時(shí)俱進(jìn)的邏輯架構(gòu)、海量數(shù)據(jù)高效存儲(chǔ)、海量數(shù)據(jù)高速加載、海量數(shù)據(jù)高性能分析、彈性服務(wù)器資源伸縮、完善的系統(tǒng)資源管理、多級(jí)別的高可用、跨

    2024年01月25日
    瀏覽(23)
  • 南大通用數(shù)據(jù)庫-Gbase-8a-報(bào)錯(cuò)集錦-02-metadata is incomplete on localhost

    南大通用數(shù)據(jù)庫-Gbase-8a-報(bào)錯(cuò)集錦-02-metadata is incomplete on localhost

    名稱 值 CPU Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz 操作系統(tǒng) CentOS Linux release 7.9.2009 (Core) 內(nèi)存 3G 邏輯核數(shù) 2 Gbase8a版本 8.6.2-R43 由于gbase.table_distribution存儲(chǔ)了所有引擎為express的表元數(shù)據(jù)信息,如果此表出現(xiàn)數(shù)據(jù)損壞,會(huì)導(dǎo)致本地調(diào)度節(jié)點(diǎn)無法獲取表信息,在select、drop等操作時(shí),將提

    2024年02月06日
    瀏覽(22)
  • 南大通用GBase 8c數(shù)據(jù)庫與泛微軟件完成互認(rèn)證 共同搭建統(tǒng)一數(shù)字化辦公平臺(tái)

    南大通用GBase 8c數(shù)據(jù)庫與泛微軟件完成互認(rèn)證 共同搭建統(tǒng)一數(shù)字化辦公平臺(tái)

    日前,南大通用分布式交易型數(shù)據(jù)庫GBase 8c與泛微協(xié)同商務(wù)軟件“e-cology” V9.0順利完成產(chǎn)品兼容性測試,雙方產(chǎn)品完全兼容,整體運(yùn)行穩(wěn)定,性能卓越。完成適配后,雙方將充分發(fā)揮在各自領(lǐng)域的專業(yè)優(yōu)勢,堅(jiān)持以客戶需求為基礎(chǔ),助力國產(chǎn)化辦公平臺(tái)實(shí)現(xiàn)數(shù)字化轉(zhuǎn)型,更好

    2024年02月13日
    瀏覽(24)
  • GBASE南大通用分享,適用于 GBase 8s ESQL/C的Insert 游標(biāo)

    關(guān)閉 Insert 游標(biāo)? 由于 GBase 8s 在 SPL 例程中不支持 Insert 游標(biāo),本節(jié)有關(guān) Insert 游標(biāo)的討論僅適用于 GBase 8s ESQL/C。在 SPL 例程中,只能執(zhí)行 DECLARE 語句定義的 Select 或 Function 游標(biāo)的 CLOSE 語句。(SPL 的 FOREACH 語句在其語句塊中包含 INSERT 語句可以聲明功能類似 Insert 游標(biāo)的 direc

    2024年01月20日
    瀏覽(18)
  • GBASE南大通用 GCDW&阿里云計(jì)算巢:自動(dòng)化部署云原生數(shù)據(jù)倉庫

    GBASE南大通用 GCDW&阿里云計(jì)算巢:自動(dòng)化部署云原生數(shù)據(jù)倉庫

    目前,GBASE南大通用已與阿里云計(jì)算巢合作,雙方融合各自技術(shù)優(yōu)勢,助力企業(yè)用戶實(shí)現(xiàn)云上數(shù)據(jù)倉庫的自動(dòng)化部署,讓用戶在云端獲取數(shù)據(jù)倉庫服務(wù)“更簡單”,讓用戶在云端使用數(shù)據(jù)倉庫服務(wù)“更便捷”,滿足企業(yè)用戶對(duì)高效便捷、自動(dòng)化部署、高性價(jià)比的云原生數(shù)據(jù)倉

    2024年02月03日
    瀏覽(17)
  • GBASE南大通用GBase 8a 安裝部署

    ssh root@192.168.7.71 ssh root@192.168.7.72 ssh root@192.168.7.73 systemctl status firewalld.service systemctl stop firewalld systemctl disable firewalld sestatus 若系統(tǒng)提示以下信息說明 selinux 已被禁用 未被禁用的話,需要修改配置文件/etc/selinux/config 將SELINUX參數(shù)設(shè)置為? disabled ,即 SELINUX=disabled 保存退出后,

    2024年02月01日
    瀏覽(25)
  • GBASE南大通用-Command 屬性

    GBASE南大通用CommandText 屬性 獲取或者設(shè)置要在數(shù)據(jù)源中執(zhí)行的 SQL 語句,默認(rèn)是空字符串。 ? 語法 [Visual Basic] Public Overrides Property CommandText As String Get Set [C#] GBASE南大通用public override string CommandText { get; set; } ? 實(shí)現(xiàn) IDbCommand.CommandText ? 注釋 當(dāng) CommandType 屬性設(shè)置為 StoredProc

    2024年02月02日
    瀏覽(19)
  • GBASE南大通用系統(tǒng)目錄表

    系統(tǒng)目錄由描述數(shù)據(jù)庫結(jié)構(gòu)的表和視圖組成。這些表對(duì)象有時(shí)稱為數(shù)據(jù)字典,它們包含 數(shù)據(jù)庫本身的所有信息。每個(gè)系統(tǒng)目錄表都包含有關(guān)數(shù)據(jù)庫中特定元素的信息。每個(gè)數(shù)據(jù) 庫都有它自己的系統(tǒng)目錄。 這些主題提供了有關(guān)系統(tǒng)目錄表的結(jié)構(gòu)、內(nèi)容和使用的信息。還包含了

    2024年02月01日
    瀏覽(45)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包