'Create the SQL for this query. Return the SQL string and list
of parameters.  This is overridden from the original Query class
to handle the additional SQL Oracle requires to emulate LIMIT
and OFFSET.
If \'with_limits\' is False, any limit/offset information is not
included in the query.'

def as_sql(self, with_limits=True, with_col_aliases=False):

    do_offset = (with_limits and ((self.query.high_mark is not None) or self.query.low_mark))
    if (not do_offset):
        (sql, params) = super().as_sql(with_limits=False, with_col_aliases=with_col_aliases)
    elif ((not self.connection.features.supports_select_for_update_with_limit) and self.query.select_for_update):
        raise NotSupportedError('LIMIT/OFFSET    is    not    supported    with    select_for_update    on    this    database    backend.')
    else:
        (sql, params) = super().as_sql(with_limits=False, with_col_aliases=True)
        high_where = ''
        if (self.query.high_mark is not None):
            high_where = ('WHERE    ROWNUM    <=    %d' % (self.query.high_mark,))
        if self.query.low_mark:
            sql = ('SELECT    *    FROM    (SELECT    "_SUB".*,    ROWNUM    AS    "_RN"    FROM    (%s)    "_SUB"    %s)    WHERE    "_RN"    >    %d' % (sql, high_where, self.query.low_mark))
        else:
            sql = ('SELECT    *    FROM    (SELECT    "_SUB".*    FROM    (%s)    "_SUB"    %s)' % (sql, high_where))
    return (sql, params)
