Aqui tienes otro ejemplo de una funcion insert:
Código SQL
[-]CREATE OR REPLACE FUNCTION insert_tip_demorada(_tipo_nombre character, _descrip_tipo character)
RETURNS boolean AS
$BODY$
begin
INSERT INTO tipo_demo(tipo_nombre,descrip_tipo) VALUES(_tipo_nombre,_descrip_tipo);
RETURN True;
exception
when integrity_constraint_violation then
RAISE NOTICE 'Rollback to savepoint';
RETURN False;
end;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;