Class: ActiveRecord::ConnectionAdapters::IBM_DB2_ZOS
- Inherits:
-
IBM_DB2
- Object
- IBM_DataServer
- IBM_DB2
- ActiveRecord::ConnectionAdapters::IBM_DB2_ZOS
- Defined in:
- lib/active_record/connection_adapters/ibm_db_adapter.rb
Overview
module HostedDataServer
Direct Known Subclasses
Instance Method Summary collapse
- #change_column_default(table_name, column_name, default) ⇒ Object
- #change_column_null(table_name, column_name, null, default) ⇒ Object
-
#create_index_after_table(table_name, column_name) ⇒ Object
since v9 doesn’t need, suggest putting it in HostedDataServer?.
- #remove_column(table_name, column_name) ⇒ Object
-
#rename_column(table_name, column_name, new_column_name) ⇒ Object
Alter table column for renaming a column.
-
#set_binary_default(value) ⇒ Object
DB2 z/OS only allows NULL or “” (empty) string as DEFAULT value for a BLOB column.
Methods inherited from IBM_DB2
#change_column, #extract_new_default_value, #get_datetime_mapping, #get_double_mapping, #get_time_mapping, #initialize, #last_generated_id, #primary_key_definition, #set_binary_value, #set_case, #set_text_default
Methods inherited from IBM_DataServer
#check_reserved_words, #execute, #get_datetime_mapping, #get_double_mapping, #get_time_mapping, #initialize, #last_generated_id, #limit_not_supported_types, #prepare, #reorg_table, #select, #select_rows, #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_DB2
Instance Method Details
#change_column_default(table_name, column_name, default) ⇒ Object
3468 3469 3470 3471 3472 3473 3474 3475 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3468 def change_column_default(table_name, column_name, default) unless default raise NotImplementedError, "DB2 for zOS data server version 9 does not support changing the column default to NULL" else super end end |
#change_column_null(table_name, column_name, null, default) ⇒ Object
3477 3478 3479 3480 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3477 def change_column_null(table_name, column_name, null, default) raise NotImplementedError, "DB2 for zOS data server does not support changing the column's nullability" end |
#create_index_after_table(table_name, column_name) ⇒ Object
since v9 doesn’t need, suggest putting it in HostedDataServer?
3418 3419 3420 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3418 def create_index_after_table(table_name,column_name) @adapter.add_index(table_name, column_name, :unique => true) end |
#remove_column(table_name, column_name) ⇒ Object
3422 3423 3424 3425 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3422 def remove_column(table_name, column_name) raise NotImplementedError, "remove_column is not supported by the DB2 for zOS data server" end |
#rename_column(table_name, column_name, new_column_name) ⇒ Object
Alter table column for renaming a column
3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3428 def rename_column(table_name, column_name, new_column_name) _table_name = table_name.to_s _column_name = column_name.to_s _new_column_name = new_column_name.to_s nil_condition = _table_name.nil? || _column_name.nil? || _new_column_name.nil? empty_condition = _table_name.empty? || _column_name.empty? || _new_column_name.empty? unless nil_condition if nil_condition || empty_condition raise ArgumentError,"One of the arguments passed to rename_column is empty or nil" end begin rename_column_sql = "ALTER TABLE #{_table_name} RENAME COLUMN #{_column_name} \ TO #{_new_column_name}" unless stmt = execute(rename_column_sql) error_msg = IBM_DB.getErrormsg(@adapter.connection, IBM_DB::DB_CONN ) if error_msg && !error_msg.empty? raise "Rename column failed : #{error_msg}" else raise StandardError.new('An unexpected error occurred during renaming the column') end end reorg_table(_table_name) ensure IBM_DB.free_stmt(stmt) if stmt end #End of begin end |
#set_binary_default(value) ⇒ Object
DB2 z/OS only allows NULL or “” (empty) string as DEFAULT value for a BLOB column. For non-empty string and non-NULL values, the server returns error
3464 3465 3466 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 3464 def set_binary_default(value) "#{value}" end |