create [or replace] function function_name(param_list) returns return_type language plpgsql as $$ declare -- variable declaration begin -- logic end; $$