How to implement User-Defined Functions(UDF) in PostgreSQL?