Cast fix that will work on both Oracle/Postgres