Due some circumtance , I had opted to use python script.. Well, for python script , you need to be extra careful with the white space and tab.. this is
Tag: function
Postgresql Function. Procedural scriptPostgresql Function. Procedural script
Postgresql can be use with procedural call also .. example as below.