Class: ActiveRecord::ConnectionAdapters::IBM_DB2_LUW
- Inherits:
-
IBM_DB2
- Object
- IBM_DataServer
- IBM_DB2
- ActiveRecord::ConnectionAdapters::IBM_DB2_LUW
- Defined in:
- lib/active_record/connection_adapters/ibm_db_adapter.rb
Overview
class IBM_DB2
Instance Method Summary collapse
- #query_offset_limit(sql, offset, limit) ⇒ Object
-
#reorg_table(table_name) ⇒ Object
Reorganizes the table for column changes.
Methods inherited from IBM_DB2
#change_column, #change_column_default, #execute, #get_datetime_mapping, #get_time_mapping, #last_generated_id, #primary_key, #rename_column, #select_all, #set_binary_default, #set_binary_value, #set_case, #set_text_default
Methods inherited from IBM_DataServer
#change_column_default, #check_reserved_words, #create_index_after_table, #execute, #get_datetime_mapping, #get_time_mapping, #initialize, #last_generated_id, #remove_column, #select_all, #set_binary_default, #set_binary_value, #set_case, #set_schema, #set_text_default, #setup_for_lob_table
Constructor Details
This class inherits a constructor from ActiveRecord::ConnectionAdapters::IBM_DataServer
Instance Method Details
#query_offset_limit(sql, offset, limit) ⇒ Object
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 1269 def query_offset_limit(sql, offset, limit) if (offset.nil?) return sql << " FETCH FIRST #{limit} ROWS ONLY" end # Defines what will be the last record last_record = offset + limit # Transforms the SELECT query in order to retrieve/fetch only # a number of records after the specified offset. # 'select' or 'SELECT' is replaced with the partial query below that adds the sys_row_num column # to select with the condition of this column being between offset+1 and the offset+limit sql.sub!(/SELECT/i,"SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM (SELECT") # The final part of the query is appended to include a WHERE...BETWEEN...AND condition, # and retrieve only a LIMIT number of records starting from the OFFSET+1 sql << ") AS I) AS O WHERE sys_row_num BETWEEN #{offset+1} AND #{last_record}" end |
#reorg_table(table_name) ⇒ Object
Reorganizes the table for column changes
1265 1266 1267 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 1265 def reorg_table(table_name) execute("CALL ADMIN_CMD('REORG TABLE #{table_name}')") end |