Postgresql Declare Cursor Example