Postgre数据库自定义函数
2024-08-26 09:50:31
自定函数
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;
参数说明:calculate_speed代表自定义函数名称 anyelement numeric参数类型 begin end函数体的开始和结束
最新文章
- Java 第16章 封装
- 密钥文件snk
- oracle一点记录
- Oracle事务之一:锁和隔离
- for循环与for in循环
- Word中批量替换软回车
- 查询制定行数的数据(2)对了,mysql不能用top关键字
- C#中A a=new B()的意义
- Project Euler problem 63
- DataTable复制自身行
- Cocos2d-X 动作展示《一》
- Ext JS学习第二天 我们所熟悉的javascript(一)
- leetcode[149]Max Points on a Line
- could not resolve host: github.com 问题解决办法
- 1129: 零起点学算法36——3n+1问题
- 求前n个素数(C++)
- rabbitmq 日志存储路径
- WordPress主题开发:按分类调用文章
- [原]Django(1)----Django-setting中的STATIC_URL 和STATIC_ROOT 和STATICFILES_DIRS 的区别
- P4592 [TJOI2018]异或