Is there a way to declare variables and use IF in plain SQL, not inplpgsql inside stored procedures?