1create [or replace] function function_name(param_list)
2 returns return_type
3 language plpgsql
4as $$
5declare
6-- variable declaration
7begin
8 -- logic
9end;
10$$
1postgres=# Create or replace function fun1(n int) returns int
2
3as
4
5$$
6
7Begin
8
9Insert into test values (n,'2019-11-26');
10
11Return 1;
12
13End;
14
15$$
16
17Language 'plpgsql';
18
19CREATE FUNCTION
20
21postgres=#