Postgresql Create Function Declare Sql Cursor W3schools