Postgre数据库自定义函数

时间:2019-11-24 20:18:50   收藏:0   阅读:323

自定函数

1、查询函数:

     select prosrc from pg_proc where proname=‘test‘  test 为函数名。

2、删除函数:

     drop function test(anyelement,anyelement,numeric)  test 为函数名。

3、定义数据库函数: 

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

原文:https://www.cnblogs.com/dongl961230/p/11923302.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!