zoukankan      html  css  js  c++  java
  • Postgre数据库自定义函数

                                                                                                                  自定函数

    1、查询函数:

        

     select prosrc from pg_proc where proname='test'

    参数说明 : test 为函数名。

    2、删除函数:

         

    1  drop function test(anyelement,anyelement,numeric)

     参数说明 : test 为函数名。

    3、定义数据库函数: 

     

    1  create or replace function calculate_speed(end_time anyelement,begin_time anyelement,length numeric) RETURNS numeric  as
    2   $$
    3      declare
    4      total_second numeric;
    5      begin
    6             select extract(epoch from((end_time::timestamp - begin_time)))/3.6 into total_second;
    7             return round(length::numeric/total_second::numeric,3);
    8      end;
    9   $$ LANGUAGE plpgsql;

     参数说明:calculate_speed代表自定义函数名称     anyelement numeric参数类型   begin end函数体的开始和结束

  • 相关阅读:
    解决哈希(HASH)冲突的主要方法
    破解
    打工
    [JSOI2007]麻将
    [JSOI2007]建筑抢修
    [HAOI2007]上升序列
    [HAOI2007]覆盖问题
    [CQOI2017]小Q的棋盘
    [HEOI2015]兔子与樱花
    [HEOI2015]定价
  • 原文地址:https://www.cnblogs.com/dongl961230/p/11923302.html
Copyright © 2011-2022 走看看