create function in postgresql
create [or replace] function function_name(param_list)
   returns return_type 
   language plpgsql
as $$
declare 
-- variable declaration
begin
 -- logic
end;
$$
                                
                            create function in postgresql
create [or replace] function function_name(param_list)
   returns return_type 
   language plpgsql
as $$
declare 
-- variable declaration
begin
 -- logic
end;
$$
                                
                            plpgsql create function
CREATE FUNCTION function_name(argument1 type,argument2 type)
 RETURNS type AS
BEGIN
  staments;
END;
LANGUAGE 'language_name';
                                
                            plpgsql create function
postgres=# Create or replace function fun1(n int) returns int 
as
$$
Begin
Insert into test values (n,'2019-11-26');
Return 1;
End;
$$
Language 'plpgsql';
CREATE FUNCTION
postgres=# 
                                
                            postgresql functions
CASE
     WHEN condition_1  THEN result_1
     WHEN condition_2  THEN result_2
     ...
     ELSE  result_n
END
                                
                            create function postgresql
CREATE OR REPLACE FUNCTION auditlogfunc() RETURNS TRIGGER AS $example_table$
   BEGIN
      INSERT INTO AUDIT(EMP_ID, ENTRY_DATE) VALUES (new.ID, current_timestamp);
      RETURN NEW;
   END;
$example_table$ LANGUAGE plpgsql;
                                
                            Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us