Postgresql Function Set Variable In T Sql If Temp Table Exists