The DB2 adapter works with the C-based CLI driver (raa.ruby-lang.org/project/ruby-db2/).
Options:
- :username — Defaults to nothing
- :password — Defaults to nothing
- :database — The name of the database. No default, must be provided.
Methods
- adapter_name
- add_limit_with_offset!
- add_limit_without_offset!
- begin_db_transaction
- columns
- commit_db_transaction
- delete
- execute
- insert
- quote_column_name
- quote_string
- rollback_db_transaction
- select_all
- select_one
- update
Public Instance methods
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 84
84: def adapter_name()
85: 'DB2'
86: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 92
92: def add_limit_with_offset!(sql, limit, offset)
93: raise ArgumentError, 'add_limit_with_offset! not implemented'
94: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 96
96: def add_limit_without_offset!(sql, limit)
97: sql << " FETCH FIRST #{limit} ROWS ONLY"
98: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 68
68: def begin_db_transaction
69: @connection.set_auto_commit_off
70: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 100
100: def columns(table_name, name = nil)
101: stmt = DB2::Statement.new(@connection)
102: result = []
103:
104: stmt.columns(table_name.upcase).each do |c|
105: c_name = c[3].downcase
106: c_default = c[12] == 'NULL' ? nil : c[12]
107: c_type = c[5].downcase
108: c_type += "(#{c[6]})" if !c[6].nil? && c[6] != ''
109: result << Column.new(c_name, c_default, c_type)
110: end
111:
112: stmt.free
113: result
114: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 72
72: def commit_db_transaction
73: @connection.commit
74: @connection.set_auto_commit_on
75: end
Alias for execute
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 52
52: def execute(sql, name = nil)
53: rows_affected = 0
54:
55: log(sql, name, @connection) do |connection|
56: stmt = DB2::Statement.new(connection)
57: stmt.exec_direct(sql)
58: rows_affected = stmt.row_count
59: stmt.free
60: end
61:
62: rows_affected
63: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 47
47: def insert(sql, name = nil, pk = nil, id_value = nil)
48: execute(sql, name = nil)
49: id_value || last_insert_id
50: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 82
82: def quote_column_name(name) name; end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 88
88: def quote_string(s)
89: s.gsub(/'/, "''") # ' (for ruby-mode)
90: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 77
77: def rollback_db_transaction
78: @connection.rollback
79: @connection.set_auto_commit_on
80: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 39
39: def select_all(sql, name = nil)
40: select(sql, name)
41: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb, line 43
43: def select_one(sql, name = nil)
44: select(sql, name).first
45: end
Alias for execute