Class | Sequel::JDBC::AS400::Dataset
In: | lib/sequel/adapters/jdbc/as400.rb
Parent: | JDBC::Dataset

Dataset class for AS400 datasets accessed via JDBC.

### Methods

select_limit_sql select_sql supports_window_functions?

### Constants

WILDCARD | = | Sequel::LiteralString.new('*').freeze

### Public Instance methods

select_limit_sql(sql)

Modify the sql to limit the number of rows returned

[Source]

        # File lib/sequel/adapters/jdbc/as400.rb, line 81
    81:         def select_limit_sql(sql)
    82:           if @opts[:limit]
    83:             sql << " FETCH FIRST ROW ONLY" if @opts[:limit] == 1
    84:             sql << " FETCH FIRST #{@opts[:limit]} ROWS ONLY" if @opts[:limit] > 1
    85:           end
    86:         end

select_sql()

AS400 needs to use a couple of subselects for queries with offsets.

[Source]

        # File lib/sequel/adapters/jdbc/as400.rb, line 63
    63:         def select_sql
    64:           return super unless o = @opts[:offset]
    65:           l = @opts[:limit]
    66:           order = @opts[:order]
    67:           dsa1 = dataset_alias(1)
    68:           dsa2 = dataset_alias(2)
    69:           rn = row_number_column
    70:           irn = Sequel::SQL::Identifier.new(rn).qualify(dsa2)
    71:           subselect_sql(unlimited.
    72:               from_self(:alias=>dsa1).
    73:               select_more(Sequel::SQL::QualifiedIdentifier.new(dsa1, WILDCARD),
    74:               Sequel::SQL::WindowFunction.new(SQL::Function.new(:ROW_NUMBER), Sequel::SQL::Window.new(:order=>order)).as(rn)).
    75:               from_self(:alias=>dsa2).
    76:               select(Sequel::SQL::QualifiedIdentifier.new(dsa2, WILDCARD)).
    77:               where(l ? ((irn > o) & (irn <= l + o)) : (irn > o))) # Leave off limit in case of limit(nil, offset)
    78:         end

supports_window_functions?()

[Source]

        # File lib/sequel/adapters/jdbc/as400.rb, line 88
    88:         def supports_window_functions?
    89:           true
    90:         end

[Validate]