Update query to work with both Oracle and Postgres