Postgresql Exception Handling In Function