PostgreSQL官方文档
http://www.postgres.cn/docs/10/index.html
Postgresql过程语言官方文档
http://www.postgres.cn/docs/10/xplang.html
Postgresql查看当前版本
select version();
PostgreSQL函数创建格式
drop function if exists [函数名];
create function [函数名] ([参数]) returns [返回值] as
$$
declare
[变量声明]
begin
[sql逻辑]
end;
$$
language 'plpgsql';
示例1
create or replace function calculate (num1 int, num2 int, opr char(1)) returns int as
$$
declare
num int;
begin
--raise notice 'num1:%,num2:%;opr:%', num1, num2, opr;
if opr = '-' then num := num1 - num2;
elseif opr = '+' then num := num1 + num2;
elseif opr =