Class: SQL::Maker::Select::Oracle
- Inherits:
-
SQL::Maker::Select
- Object
- SQL::Maker::Select
- SQL::Maker::Select::Oracle
- Defined in:
- lib/sql/maker/select/oracle.rb
Instance Attribute Summary
Attributes inherited from SQL::Maker::Select
#auto_bind, #for_update, #from, #group_by, #having, #index_hint, #joins, #name_sep, #new_line, #order_by, #quote_char, #select, #select_map, #select_map_reverse, #strict, #subqueries, #where
Instance Method Summary collapse
-
#as_limit ⇒ Object
Oracle doesn’t have the LIMIT clause.
-
#as_sql ⇒ Object
Override as_sql to emulate the LIMIT clause.
Methods inherited from SQL::Maker::Select
#_add_index_hint, #_quote, #add_from, #add_group_by, #add_having, #add_index_hint, #add_join, #add_order_by, #add_select, #add_where, #add_where_raw, #as_sql_for_update, #as_sql_group_by, #as_sql_having, #as_sql_limit, #as_sql_order_by, #as_sql_where, #bind, #distinct, #initialize, #limit, #new_condition, #offset, #prefix, #set_where
Methods included from Util
#array_wrap, #bind_param, bind_param, #croak, included, #parse_args, #quote_identifier, quote_identifier
Constructor Details
This class inherits a constructor from SQL::Maker::Select
Instance Method Details
#as_limit ⇒ Object
Oracle doesn’t have the LIMIT clause.
5 6 7 |
# File 'lib/sql/maker/select/oracle.rb', line 5 def as_limit return '' end |
#as_sql ⇒ Object
Override as_sql to emulate the LIMIT clause.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sql/maker/select/oracle.rb', line 10 def as_sql limit = self.limit offset = self.offset if limit && offset self.add_select( "ROW_NUMBER() OVER (ORDER BY 1) R" ) end sql = super if limit sql = "SELECT * FROM ( #{sql} ) WHERE " if offset sql = sql + " R BETWEEN #{offset} + 1 AND #{limit} + #{offset}" else sql = sql + " rownum <= #{limit}" end end return sql end |