Module: ArJdbc::AS400

Includes:
DB2
Included in:
ActiveRecord::ConnectionAdapters::AS400Adapter
Defined in:
lib/arjdbc/db2/as400.rb

Constant Summary collapse

ADAPTER_NAME =
'AS400'.freeze
DRIVER_NAME =
'com.ibm.as400.access.AS400JDBCDriver'.freeze

Constants included from DB2

DB2::HAVE_LIMIT, DB2::HAVE_PRECISION, DB2::HAVE_SCALE, DB2::NATIVE_DATABASE_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DB2

#add_column, #add_column_options!, #add_index, #add_limit_offset!, #change_column, #change_column_default, #change_column_null, #columns, #configure_connection, #create_table, #drop_database, #empty_insert_statement_value, emulate_booleans?, #indexes, #jdbc_column_class, #last_inserted_id, #modify_types, #native_database_types, #next_sequence_value, #pk_and_sequence_for, #primary_keys, #quote, #quote_column_name, #quote_time, #quoted_date, #recreate_database, #remove_column, #remove_index!, #rename_table, #reset_column_information, #runstats_for_table, #schema, #schema=, #select, #supports_views?, #table_definition, #tables, #truncate, #type_to_sql, #update_lob_value?, update_lob_values=, update_lob_values?

Class Method Details

.column_selectorObject



28
29
30
# File 'lib/arjdbc/db2/as400.rb', line 28

def self.column_selector
  [ /as400/i, lambda { |config, column| column.extend(Column) } ]
end

.emulate_booleansObject

Boolean emulation can be disabled using :

ArJdbc::AS400.emulate_booleans = false



36
# File 'lib/arjdbc/db2/as400.rb', line 36

def self.emulate_booleans; DB2.emulate_booleans; end

.emulate_booleans=(emulate) ⇒ Object



37
# File 'lib/arjdbc/db2/as400.rb', line 37

def self.emulate_booleans=(emulate); DB2.emulate_booleans = emulate; end

.jdbc_connection_classObject



26
# File 'lib/arjdbc/db2/as400.rb', line 26

def self.jdbc_connection_class; DB2.jdbc_connection_class; end

Instance Method Details

#adapter_nameObject



41
42
43
# File 'lib/arjdbc/db2/as400.rb', line 41

def adapter_name
  ADAPTER_NAME
end

#execute_table_change(sql, table_name, name = nil) ⇒ Object



61
62
63
# File 'lib/arjdbc/db2/as400.rb', line 61

def execute_table_change(sql, table_name, name = nil)
  execute_and_auto_confirm(sql, name)
end

#prefetch_primary_key?(table_name = nil) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
# File 'lib/arjdbc/db2/as400.rb', line 46

def prefetch_primary_key?(table_name = nil)
  # TRUE if the table has no identity column
  names = table_name.upcase.split(".")
  sql = "SELECT 1 FROM SYSIBM.SQLPRIMARYKEYS WHERE "
  sql << "TABLE_SCHEM = '#{names.first}' AND " if names.size == 2
  sql << "TABLE_NAME = '#{names.last}'"
  select_one(sql).nil?
end

#rename_column(table_name, column_name, new_column_name) ⇒ Object

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/arjdbc/db2/as400.rb', line 56

def rename_column(table_name, column_name, new_column_name)
  raise NotImplementedError, "rename_column is not supported on IBM iSeries"
end

#table_exists?(name) ⇒ Boolean

disable all schemas browsing when default schema is specified

Returns:

  • (Boolean)


99
100
101
102
# File 'lib/arjdbc/db2/as400.rb', line 99

def table_exists?(name)
  return false unless name
  schema ? @connection.table_exists?(name, schema) : @connection.table_exists?(name)
end