Updating conditional queries to handle Oracle