Fixed oracle sql generation