db2 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGES +181 -0
  3. data/LICENSE +18 -0
  4. data/MANIFEST +14 -0
  5. data/ParameterizedQueries README +39 -0
  6. data/README +282 -0
  7. data/ext/Makefile.nt32 +181 -0
  8. data/ext/extconf.rb +66 -0
  9. data/ext/ibm_db.c +11166 -0
  10. data/ext/ruby_ibm_db.h +236 -0
  11. data/ext/ruby_ibm_db_cli.c +738 -0
  12. data/ext/ruby_ibm_db_cli.h +431 -0
  13. data/init.rb +42 -0
  14. data/lib/IBM_DB.rb +2 -0
  15. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +2558 -0
  16. data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
  17. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
  18. data/test/cases/adapter_test.rb +202 -0
  19. data/test/cases/associations/belongs_to_associations_test.rb +486 -0
  20. data/test/cases/associations/cascaded_eager_loading_test.rb +183 -0
  21. data/test/cases/associations/eager_test.rb +862 -0
  22. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +917 -0
  23. data/test/cases/associations/has_many_through_associations_test.rb +461 -0
  24. data/test/cases/associations/join_model_test.rb +793 -0
  25. data/test/cases/attribute_methods_test.rb +621 -0
  26. data/test/cases/base_test.rb +1486 -0
  27. data/test/cases/calculations_test.rb +362 -0
  28. data/test/cases/finder_test.rb +1088 -0
  29. data/test/cases/fixtures_test.rb +684 -0
  30. data/test/cases/migration_test.rb +2014 -0
  31. data/test/cases/schema_dumper_test.rb +232 -0
  32. data/test/cases/validations/uniqueness_validation_test.rb +283 -0
  33. data/test/connections/native_ibm_db/connection.rb +42 -0
  34. data/test/ibm_db_test.rb +25 -0
  35. data/test/models/warehouse_thing.rb +5 -0
  36. data/test/schema/i5/ibm_db_specific_schema.rb +135 -0
  37. data/test/schema/ids/ibm_db_specific_schema.rb +138 -0
  38. data/test/schema/luw/ibm_db_specific_schema.rb +135 -0
  39. data/test/schema/schema.rb +647 -0
  40. data/test/schema/zOS/ibm_db_specific_schema.rb +206 -0
  41. metadata +105 -0
@@ -0,0 +1 @@
1
+ *.gem
data/CHANGES ADDED
@@ -0,0 +1,181 @@
1
+ Change Log
2
+ ==============
3
+ 2011/02/07 (IBM_DB adapter 2.5.6, driver 2.5.6) :
4
+ - Fixed Bug #28622, #28881
5
+ - Decimal datatypes will now be returned as BigDecimal type from the driver
6
+ - Changes to rollback any active transaction in the connection destructor method if connection is not explicitly closed
7
+ - Changes to have a single gem file for ruby 1.8 and ruby 1.9
8
+ 2010/07/15 (IBM_DB adapter 2.5.5, driver 2.5.5) :
9
+ - Support for datatype Graphic and Vargraphic in driver and adapter [27965]
10
+ - Support for Bigint datatype in adapter.
11
+ - Fixed bug [28295] --> IBM_DB, Unicode Version, fails with encoding error against Informix Server
12
+
13
+ 2010/05/12 (IBM_DB adapter 2.5.0, driver 2.5.0) :
14
+ - Support for Unicode with Ruby 1.9 [Data from the IBM_DB driver is returned in UTF8 format]
15
+ - Fixed bug [27954] --> Fixed Truncation of char for bit data containing a Null Terminator
16
+ - Removed handling of NilClass type data in quote method. Super class will handle appropriately.
17
+
18
+ 2010/01/21 (IBM_DB adapter 2.0.0, driver 2.0.0) :
19
+ - Support for usage of parameterized SQL queries
20
+ - Exposed constant VERSION in the driver [Feature Request: #27231]
21
+
22
+ 2009/08/21 (IBM_DB adapter 1.5.0, driver 1.5.0) :
23
+ - non-block enhancement in the ruby driver made for Ruby version 1.9. [support request #25023]
24
+ - New API's getErrormsg and getErrorstate for retrieving error messages/state added
25
+ - Re-defined raising of exception from driver. [Bug #26544]
26
+ - Made adapter changes as per the new API's exposed in the driver for retrieving error messages
27
+ - API's conn_errormsg and stmt_errormsg is been deprecated.
28
+
29
+ 2009/07/28 (IBM_DB adapter 1.1.1, driver 1.1.0) :
30
+ - Fixed bug [26705] --> Fixed the problem of primary key value starting with 100
31
+ - Support for Activerecord-2.3.3
32
+ - Added method primary_key, which returns the primary key column name of the specified table
33
+ - Test suite updated
34
+
35
+ 2009/06/17 (IBM_DB adapter 1.1.0, driver 1.1.0) :
36
+ - Support for Activerecord's Query Cache Mechanism
37
+ - rename_column support for DB2 on LUW version 9.7, DB2 on zOS 9 and enhanced rename_column support for Informix Dynamic Server
38
+ - Support for parameterized timestamp datatype feature of DB2 on LUW Version 9.7
39
+ - Enhanced support for Bigint datatype along with support for Bigserial datatype (with client version 9.7 and above) of IDS
40
+ - Callback method handle_lobs enhanced by making it to use prepared statements completely
41
+ - Handling of exceptions during fetch operations enabled
42
+
43
+ 2009/03/24 (IBM_DB adapter 1.0.5, driver 1.0.5) :
44
+ - Support for Ruby-1.9.1
45
+ - Support for SQLRowcount in driver
46
+ - Support for Activerecord-2.3.2 [test suite updated]
47
+ - Fixed bug [24663] --> Fixed pre-mature clearing of the sql array in handle_lobs
48
+ - Fixed bug [23115] --> Fixed truncation of a nested query during update
49
+ - Fixed wrong setting of SQLID for schema on zOS 8 dataserver when schema is explicitly specified.
50
+
51
+ 2009/03/06 (IBM_DB adapter 1.0.2, driver 1.0.1) :
52
+ - Support for specifying connection timeout in adapter
53
+ - Fixed Bug [23317] --> Fixed assumption of id as the primary key while updation/insertion of lob fields
54
+ - Fixed Bug [23389] --> Provided proper exception handling.
55
+ - Fixed the insertion of incorrect value for lob objects in case of has_and_belongs_to_many associations.
56
+
57
+ 2008/12/18 (IBM_DB adapter 1.0.1, driver 1.0.1) :
58
+ - Support for datatype decfloat
59
+ - Changes in installation process. Now user should set IBM_DB_INCLUDE env variable instead of IBM_DB_DIR
60
+ - Support for specifying the Authentication type to be used during connection in adapter
61
+ - Corrected the ignorance of a connection, when the connection is successful with a warning
62
+ - ActiveRecord-2.2.2 test suite changes for IBM_DB
63
+ 2008/11/06 (IBM_DB adapter 1.0.0, driver 0.10.0):
64
+ - Support for short-hand migration syntax for datatype char and double in create_table
65
+ - Support for short-hand migration syntax for datatypes xml, char and double in change_table
66
+ - Support for secure connections using SSL (SECURITY=SSL) feature of DB2 in Adapter
67
+ Note: - This is supported from client version V9.5fp2 and onwards
68
+ - Support for altering the nullability constraint of a column.
69
+ - Added correct mapping for datatype :double for DB2 and Informix (double precision)
70
+ - Method support_ddl_transactions? overridden to return true. Feature of Rails2.2
71
+ IBM Dataservers support transactional migrations.
72
+ - Change in the style of accessing driver methods
73
+ Changed from scope resolution operator to dot operator
74
+ IBM_DB::connect '<db_name>','<username>','<pwd>' to IBM_DB.connect '<db_name>','<username>','<pwd>'
75
+ - Fixed Bug [#22430] --> Fixed limit ignorance for type character [char]
76
+ - ActiveRecord-2.1.2 test suite changes for IBM_DB
77
+
78
+ 2008/09/01 (IBM_DB adapter 0.10.0, driver 0.10.0):
79
+ - Added Trusted Context support in Driver
80
+ - Made changes for the correct Mapping of Informix DataTypes to Ruby DataTypes
81
+ - ActiveRecord-2.1.0 test suite changes appropriate for DB2/IDS is been updated
82
+
83
+ 2008/06/24 (IBM_DB adapter 0.9.5, driver 0.9.5):
84
+ - Fixed Bug [#19222] --> Fixed fixture insertion of LOB columns for DB2
85
+ - Fixed Bug [#19970] --> Fixed Table schema dumper also dump views
86
+ - Fixed Bug [#20053] --> Fixed CLOB data with special chars contains null characters upon retrieval
87
+ - Fixed Bug [#20762] --> IBM_DB adapter with Rails 2.1 fails on rake db:migrate
88
+ - Cleaned up fix for Bug [#19223] and [#19224], indexes are now dumped as array without schema qualified name.
89
+ - Support for Rails-2.0.2
90
+ - Support for Rails-2.1.0
91
+ Rails-2.1.0 contains changes that generates Non-standard SQL in 2 noticed cases which won't work with SQL compliant databases like DB2
92
+ a. Handling Nullable columns in Table creation. [http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/398-non-standard-sql-generated-in-column-definition-for-nullable-columns-in-create-table-ddl-rails-2-1#ticket-398-2]
93
+ A workaround for this problem is provided from within ibm_db adapter.
94
+ b. Handling has_and_belongs_to_many association. [http://rails.lighthouseapp.com/projects/8994/tickets/394-patch-fixed-non-standard-sql-generated-by-preloading-has_and_belongs_to_many-associations].
95
+ It is not possible to provide a workaround for this from within the ibm_db adapter.
96
+ To workaround this problem please patch ActiveRecord-2.1.0 with the patch available at [http://rails.lighthouseapp.com/attachments/26975/association_preloading.diff]
97
+
98
+ 2008/04/28 (IBM_DB adapter 0.9.4, driver 0.9.4):
99
+ - Fixed bug [#19679]--> invalid values being returned for blank or null in fetch_assoc
100
+ - Fixed bug [#19223] and [#19224]--> handling of composite and unique indexes incorrect
101
+ - Support for the Rails2.0 type of migrations for columns of type xml [t.xml :xml_col1,:xml_col2]
102
+
103
+ 2008/03/10 (IBM_DB adapter 0.9.3, driver 0.9.3):
104
+ - Resolved the issue of truncation of output when stored procedure was called
105
+
106
+ 2007/11/30 (IBM_DB adapter 0.9.2, driver 0.9.1):
107
+ - Lifted index length limitation (18 chars) and fixed multiple index creation
108
+ - Fixed [#13294] limit/offset breaks subselect in db2 adapter
109
+ - Fixed error handling for metadata retrieval (tables, columns, indexes)
110
+
111
+ 2007/11/07 (IBM_DB adapter 0.9.1, driver 0.9.1):
112
+ - Fixed ibm_db driver VC80 runtime issue on Windows
113
+
114
+ 2007/09/28 (IBM_DB adapter 0.9.0, driver 0.9.0):
115
+ - Fixed ibm_db gem 0.8.5 incompatibility with DB2 CLI 9.1 FP3 and below
116
+
117
+ 2007/09/13 (IBM_DB adapter 0.8.5, driver 0.8.5):
118
+ - Fixed Ruby driver crash on Windows Vista [#13357]
119
+
120
+ 2007/07/05 (IBM_DB adapter 0.8.0, driver 0.7.0):
121
+ - Support for Informix Dynamic Server 11.10
122
+ - New driver method get_last_serial_value to retrieve last inserted serial
123
+ value for Informix Dynamic Server
124
+
125
+ 2007/06/19 (IBM_DB adapter 0.7.5, driver 0.6.0):
126
+ - Driver code (ibm_db.c) remains at the same level: 0.6.0 (no changes)
127
+ - Fixed client attributes initialization on connection setup [11264]
128
+ - Fixed rake db:schema:dump native data types limits incompatible with table create
129
+
130
+ 2007/06/01 (IBM_DB adapter 0.7.0, driver 0.6.0):
131
+ - Driver code (ibm_db.c) remains at the same level: 0.6.0 (no changes)
132
+ - Fixed remaining failure on {:null => true} option for XML data type [#10877]
133
+ - Fixed handling of {:id => false} option during table creation in DB2 for zOS
134
+ - Fixed handle_lobs failures in table creation for has_many/belongs_to [#10701]
135
+ - Fixe db2-i5-zOS.yaml content (removed inadvertent tab) [#11234]
136
+
137
+ 2007/05/10 (IBM_DB adapter 0.6.5, driver 0.6.0):
138
+ - Driver code (ibm_db.c) remains at the same level: 0.6.0 (no changes)
139
+ - Fixed regression for reconnect after being inactive (connection recycle)
140
+ - Fixed rake db:schema:load failures on boolean data type [#10683]
141
+ - Fixed XML default option (:null => true for XML data type) [#10754]
142
+ - Fixed DB2 for zOS version 9 handling of column changes for DEFAULT NULL
143
+
144
+ 2007/04/30 (0.6.0):
145
+ - Support for remote connections to DB2 Universal Database on z/OS version 9
146
+ - Support for result set pagination via ActiveRecord add_limit_offset! method
147
+ for DB2 Universal Database on z/OS and i5/OS
148
+ - Defect fixes
149
+ - Improved documentation
150
+
151
+ 2007/04/20 (0.4.6):
152
+ - Fixed XML columns creation default value (NOT NULL)
153
+ - Fixed border case for IS NULL in where clauses
154
+ - Improved documentation (connection attributes)
155
+
156
+ 2007/04/20 (0.4.5):
157
+ - Fixed reconnect problems: driver (IBM_DB::active) and adapter (active)
158
+ - Client connection attribute rename (app_user to replace user)
159
+ - Improved support for ROWID data type (DB2 for zOS version 8 and 9)
160
+
161
+ 2007/03/21 (0.4.0):
162
+ - Support added for remote connectivity to DB2 zOS version 8
163
+ - Support added for remote connectivity to DB2 i5 v5r3 and v5r4
164
+ - Improved migration support (added change_column method)
165
+ - Support for setting and retrieving values for client attributes (user,
166
+ account, application, workstation)
167
+
168
+ 2006/10/31 (0.2.0):
169
+ - Significant performance improvements
170
+ - Improved stored procedure support at driver level
171
+ - Added support for Large Object data types (LOBs) greater than 32K (BLOB, CLOB, XML) in size
172
+ - Added XML data type support for native storage of XML documents
173
+ - Significant quality improvements, through many bug fixes in the driver and adapter
174
+ - Improved migration support (added add_column and remove_column methods)
175
+
176
+ 2006/06/07 (0.1.0):
177
+
178
+ - Fixed compatibility issue with other adapters
179
+ - If a schema is omitted in database.yml, the username is now used as default schema
180
+ - Introduced descriptive CLI error messages when a connection or an execute statement fails
181
+ - Introduced check against schema in method 'indexes'
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2006, 2007, 2008, 2009, 2010 IBM Corporation
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included
11
+ in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ CHANGES
2
+ README
3
+ LICENSE
4
+ ext/extconf.rb
5
+ ext/ibm_db.c
6
+ ext/ruby_ibm_db.h
7
+ lib/IBM_DB.rb
8
+ lib/linux32/ibm_db.so
9
+ lib/mswin32/ibm_db.so
10
+ lib/active_record/connection_adapters/ibm_db_adapter.rb
11
+ lib/active_record/vendor/db2-i5-zOS.yaml
12
+ test/activerecord/native_ibm_db/connection.rb
13
+ test/ibm_db_test.rb
14
+ MANIFEST
@@ -0,0 +1,39 @@
1
+ +-------------------------------------------+-------------------------------------------+
2
+ | README for Parameterized Queries Support in Ruby-on-Rails/ Activerecord applications |
3
+ +-------------------------------------------+-------------------------------------------+
4
+
5
+ Enabling Usage of Parameterized Queries with Ruby-on-Rails / Activerecord applications
6
+ ======================================================================================
7
+ To enable usage of parameterized SQL queries with Ruby-on-Rails/ActiveRecord applications, in your connection configuration (database.yml), set "parameterized" to true. By default "parameterized" is false (if not specified). A sample database.yml file showing development section with parameterized queries enabled looks as below
8
+
9
+ development:
10
+ adapter: ibm_db
11
+ username: db2inst1
12
+ password: secret
13
+ database: devdb
14
+ #schema: db2inst1
15
+ #host: localhost
16
+ #port: 50000
17
+ #account: my_account
18
+ #app_user: my_app_user
19
+ #application: my_application
20
+ #workstation: my_workstation
21
+ parameterized: true
22
+
23
+ Similarly for the other sections (test/production) of the database.yml file set "parameterized" to true to enable usage of parameterized SQL queries
24
+
25
+ Supported Activerecord Versions
26
+ ===============================
27
+ Activerecord-2.3.3, Activerecord-2.3.4, Activerecord-2.3.5
28
+
29
+ Supported Operating Systems and Databases
30
+ =========================================
31
+ Refer the main README
32
+
33
+ Feedback
34
+ ========
35
+ Your feedback is very much appreciated and expected through Rubyforge:
36
+ - rubyibm project: http://rubyforge.org/projects/rubyibm/
37
+ - rubyibm forum: http://rubyforge.org/forum/?group_id=2361
38
+ - rubyibm bug reports: http://rubyforge.org/tracker/?group_id=2361
39
+ - IBM_DB developers: rubyibm-developers@rubyforge.org
data/README ADDED
@@ -0,0 +1,282 @@
1
+ =====================================================================
2
+ README for the IBM_DB Adapter (2.5.5) and Driver (2.5.5) (2011/02/07)
3
+ For ActiveRecord Version >= 1.15.5 (and Rails >= 1.2.5)
4
+ =====================================================================
5
+
6
+ Supported Operating Systems
7
+ ============================
8
+ - Linux 32/64 bit
9
+ - Microsoft Windows 32 bit
10
+ - IBM AIX 32/64 bit
11
+ - HP-UX 32/64 bit
12
+ - Sun Solaris 32/64 bit
13
+
14
+
15
+ Supported Databases
16
+ ====================
17
+ - IBM DB2 Universal Database on Linux/Unix/Windows versions 8 Fixpak15 or 9 Fixpak2 and above
18
+ - Remote connections to IBM DB2 Universal Database on i5/OS versions V5R3 and V5R4.
19
+ Please ensure PTF SI27358 (includes SI27250) is installed in i5/OS version 5R3 and
20
+ and PTF SI27256 is installed while using i5/OS version 5R4.
21
+ - Remote connections to IBM DB2 Universal Database on z/OS version 8 and 9
22
+ - Informix Dynamic Server 11.10 and beyond.
23
+ Please ensure that the IBM DataServer Viper 2 client is installed.
24
+
25
+
26
+ Installing the IBM_DB adapter and driver as a Ruby gem
27
+ =======================================================
28
+ The IBM_DB gem is an ActiveRecord adapter. Installing the IBM_DB adapter and driver as a gem enables any application in the
29
+ Ruby environment, including Rails, to interact with IBM data servers.
30
+
31
+ Note : - 1) If using activerecord version below 2.0 then it requires that the ibm_db adapter be registered with the list of connection adapters by manually adding ibm_db at line 77 (approx) in the file activerecord.rb (GEM_HOME\activerecord-<version>\lib\).
32
+
33
+ 2) The IBM_DB driver can also be built separately (from source) and used in direct API calls.
34
+
35
+ 1. Windows platforms:
36
+ =====================
37
+ INSTALL (as Ruby gem)
38
+ To remove previous gem version (optionally):
39
+ D:\>gem uninstall ibm_db
40
+ Successfully uninstalled ibm_db version 0.6.0
41
+
42
+ Example:
43
+ D:\>gem install ibm_db
44
+ Bulk updating gem source index for: http://gems.rubyforge.org
45
+ Select which gem to install for your platform (i386-mswin32)
46
+ 1. ibm_db 1.0.0 (mswin32)
47
+ 2. ibm_db 1.0.0 (ruby)
48
+ 3. ibm_db 0.10.0 (mswin32)
49
+ 4. ibm_db 0.10.0 (ruby)
50
+
51
+ Running gem install ibm_db you are presented with two choices for each release
52
+ (mswin32 or ruby)choose mswin32. This will install the IBM_DB gem containing
53
+ the pre-built binary file of the driver which is a C-extension of Ruby.
54
+
55
+ TEST (simple gem install verification)
56
+ Note: The manual step after install if using activerecord version below 2.0:
57
+ add ibm_db into GEM_HOME\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
58
+ D:\rails NewApp
59
+ D:\cd NewApp
60
+ D:\NewApp>irb
61
+ irb(main):001:0> gem 'ibm_db'
62
+ irb(main):002:0> require 'mswin32/ibm_db' // notice the [mswin32] in the library path
63
+ irb(main):003:0> IBM_DB.connect 'sample', 'db2admin', 'secret'
64
+ D:\NewApp>ruby script\console
65
+
66
+
67
+ 2. Linux and Unix platforms:
68
+ ============================
69
+
70
+ INSTALL (as Ruby gem)
71
+ To remove previous gem version (optionally):
72
+ $ gem uninstall ibm_db
73
+ Successfully uninstalled ibm_db version 0.6.0
74
+
75
+ Note: DB2 environment is required while using an arbitrary user account
76
+ (other than the DB2 install user account)
77
+ $ . /home/db2inst1/sqllib/db2profile
78
+ $ export IBM_DB_INCLUDE=DB2HOME/include (eg. /home/db2inst1/sqllib/include or /opt/ibm/db2/v9.5/include)
79
+ $ export IBM_DB_LIB=DB2HOME/lib (eg. /home/db2inst1/sqllib/lib or /opt/ibm/db2/V9.5/lib32)
80
+ $ gem install ibm_db
81
+ Select which gem to install for your platform (i686-linux)
82
+ 1. ibm_db 1.0.0 (mswin32)
83
+ 2. ibm_db 1.0.0 (ruby)
84
+ 3. ibm_db 0.10.0 (ruby)
85
+ 4. ibm_db 0.10.0 (mswin32)
86
+ ...
87
+ Running gem install ibm_db you are presented with two choices for each release
88
+ (mswin32 or ruby) choose ruby. This will build the native extension (ibm_db driver) and installs the ibm_db gem.
89
+ ...
90
+ > 2
91
+ Building native extensions. This could take a while...
92
+ Successfully installed ibm_db-0.6.5
93
+ Installing ri documentation for ibm_db-0.6.5...
94
+ Installing RDoc documentation for ibm_db-0.6.5...
95
+
96
+ TEST (simple gem install verification)
97
+ Note: The manual step after install, if using activerecord version below 2.0 is:
98
+ add ibm_db into GEM_HOME\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
99
+ $ irb
100
+ irb(main):001:0> gem 'ibm_db'
101
+ irb(main):002:0> require 'ibm_db' // notice the library path (different on win32, use require 'mswin32/ibm_db')
102
+ irb(main):003:0> IBM_DB.connect 'sample', 'db2admin', 'secret'
103
+ $
104
+
105
+ BUILD (optionally) ibm_db gem from sources (ibm_db-x.x.x.tar.gz):
106
+ 1. Download source from Rubyforge
107
+ http://rubyforge.org/frs/?group_id=2361
108
+ 2. Build gem from specification (IBM_DB.gemspec)
109
+ $ cd IBM_DB_Adapter/ibm_db
110
+ $ gem build IBM_DB.gemspec
111
+
112
+
113
+ Instructions for building and installing the IBM_DB driver from source
114
+ =======================================================================
115
+ Building the driver manually as described below is not required if the install
116
+ process above has been pursued. This manual procedure is in fact automated
117
+ on Linux and UNIX platforms by the IBM_DB gem install, but is presented
118
+ here only for reference, and also involves running the unit tests.
119
+
120
+ Prerequisites:
121
+ Install Ruby from:
122
+ http://rubyforge.org
123
+
124
+ Linux and Unix platforms:
125
+ Note: commands may vary depending on the shell used
126
+ - To setup DB2 environment while using an arbitrary user account
127
+ (other than the DB2 install user account):
128
+ Example:
129
+ $ . /home/db2inst1/sqllib/db2profile
130
+
131
+ - To configure test database:
132
+ DB2 v9.x: some IBM_DB driver tests require a UTF-8 database:
133
+ $ db2 CREATE DATABASE testdrv USING CODESET UTF-8 \
134
+ TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768
135
+ DB2 v8.x: driver tests 195 and 52949 requires XML functionality
136
+ only available in DB2 v9.x
137
+
138
+ - To configure database connection parameters edit config.yaml
139
+ Example:
140
+ database: testdrv
141
+ user: db2inst1
142
+ password: password
143
+ hostname: localhost
144
+ port: 50000
145
+
146
+ - To compile and link with DB2 client libraries:
147
+ $ export IBM_DB_INCLUDE=DB2HOME/include (eg. /home/db2inst1/sqllib/include or /opt/ibm/db2/v9.5/include)
148
+ $ export IBM_DB_LIB=DB2HOME/lib (eg. /home/db2inst1/sqllib/lib or /opt/ibm/db2/V9.5/lib32)
149
+
150
+ Windows platforms:
151
+ - Install Visual C++ 2005, Platform SDK (latest), .Net SDK (latest)
152
+ - Set environment:
153
+ CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2005\SetEnv.Cmd"
154
+ CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2005\vcvars32.bat"
155
+ SET LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2005\Vc8\lib
156
+ - To configure database connection parameters edit config.yml
157
+
158
+ Build and Execution:
159
+ rake
160
+
161
+ Execution of tests without compilation (must have .so in ibm_db source directory):
162
+ rake onlytests
163
+
164
+ Execution of a single test inside the tests directory can be done by the following:
165
+ export SINGLE_RUBY_TEST=test_001_CtlgConn.rb
166
+ rake
167
+
168
+
169
+ Limitations and known problems
170
+ ==============================
171
+ - ActiveRecord rename_column method is not supported for DB2 LUW, zOS and i5
172
+ - ActiveRecord remove_column method is not supported for DB2 zOS
173
+ - The following tests from the ActiveRecord 1.15.3 test suite with ibm_db gem < 0.9.5 are expected to fail
174
+ - test_limited_eager_with_multiple_order_columns
175
+ - test_limited_eager_with_order
176
+ - test_assign_ids_ignoring_blanks
177
+ - test_build_by_new_record
178
+ - test_get_ids
179
+ - test_select_limited_ids_list
180
+ - test_add_index
181
+ - The following tests from the driver test suite are expected to fail on DB2 version 8
182
+ on Linux/Unix/Windows and Informix Dynamic Server because of missing native XML support. If you want to
183
+ make use of the native XML features in DB2, please upgrade to version 9 or later
184
+ - test_195.rb
185
+ - test_52949.rb
186
+ - The driver returns an error when you try to insert a TIMESTAMP value into a DATE column.
187
+ To fix this, please ensure that the following configuration keyword PATCH2=58 is set
188
+ in the COMMON section of your DB2 CLI initialization file (db2cli.ini):
189
+ - set: db2 UPDATE CLI CFG FOR SECTION COMMON USING PATCH2 58
190
+ - verify: db2 GET CLI CFG FOR SECTION COMMON
191
+ Please refer to http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0007882.htm
192
+ for more information.
193
+ - The behaviour of ActiveRecord::Base.find(:first) without an :order attribute can be unpredictable.
194
+ The first record (i.e. the record with the minimum id) may be not be retrieved. In a relational model,
195
+ the order of the rows returned is unpredictable and independent of the order of insertion.
196
+ This issue may be addressed in a future release.
197
+ - Rails applications on DB2 9 require the APPLHEAPSZ database configuration parameter to be
198
+ set to or above 1024. You will need to set this parameter for each database for which you will be
199
+ running DB2 on Rails applications. Following is the command syntax for updating the
200
+ applheapsz parameter:
201
+ > db2 update db cfg for <database_name> using APPLHEAPSZ 1024
202
+ To enable this parameter, you need to restart your DB2 instance.
203
+ - If you see connectivity issues with Informix Dynamic Server, please ensure that the server is configured to accept DRDA connections.
204
+ Please refer to http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.admin.doc/admin154.htm for more information.
205
+ - The following tests from the ActiveRecord 1.15.3 test suite with ibm_db gem < 0.9.5 are expected to fail on Informix Dynamic Server
206
+ - test_quote
207
+ - test_to_xml
208
+ - test_should_calculate_grouped_by_function
209
+ - test_should_calculate_grouped_by_function_with_table_alias
210
+ - test_inserts_with_pre_and_suffix
211
+ - test_add_table_with_decimals
212
+ - test_no_limits_datatypes_IBM_DB
213
+ - test_instance_update_should_quote_pkey
214
+ - test_integer_columns
215
+ - test_arguments_line_up
216
+ - test_no_dump_errors
217
+ - test_schema_dump_includes_decimal_options
218
+ - IBM_DB is not supported on JRuby. As stated in the JRuby Wiki, "Basics of Getting JRuby Running":
219
+ 'You may install other gems, but keep in mind that libraries with C extension dependencies
220
+ will not work in JRuby.' http://www.headius.com/jrubywiki/index.php/Getting_Started
221
+ The IBM_DB adapter relies on IBM_DB driver (C extension) and the IBM Driver for ODBC and
222
+ CLI to access databases on IBM data servers. Alternatively, you can either use the regular C
223
+ implementation of Ruby, or use ActiveRecord-JDBC adapter to access databases.
224
+ - Query caching feature of ActiveRecord-2.0 not supported
225
+ - When using ActiveRecord-2.1.0 it requires that ActiveRecord be patched, with the patch in the link below:
226
+ http://rails.lighthouseapp.com/attachments/26975/association_preloading.diff
227
+ The patch is required because, ActiveRecord 2.1.0 generates a non-standard SQL identifier,while preloading has_and_belongs_to_many associations,
228
+ which standard compliant databases like DB2 do not support. The bug report, against ActiveRecord, can be found in the link below
229
+ http://rails.lighthouseapp.com/projects/8994/tickets/394-patch-fixed-non-standard-sql-generated-by-preloading-has_and_belongs_to_many-associations
230
+ - ActiveRecord-2.1.0 test suite changes appropriate for DB2/IDS will be updated in the next release of the gem.(Updated in release 0.10.0)
231
+ - The following tests from the ActiveRecord 2.1.0 test suite with ibm_db gem 0.10.0 are expected to fail on DB2 LUW
232
+ - test_read_attributes_before_type_cast_on_datetime
233
+ - test_to_xml
234
+ - test_native_types
235
+ - test_counting
236
+ - test_counting_with_column_name_and_hash
237
+ - test_counting_with_empty_hash_conditions
238
+ - test_counting_with_single_conditions
239
+ - test_counting_with_single_hash
240
+ Note :- 1) The test cases from HasManyAssociations (4-8) above are found failing only when run as part of
241
+ the complete suite. However they pass when run standalone.
242
+ 2) Also there are two test cases (test_validate_uniqueness_with_non_standard_table_names, test_update_all_with_non_standard_table_name)which run against table with non-standard name. Given that DB2/IDS is standard compliant these test cases are expected to fail.
243
+ To have these test cases passing rename the fixtures file warehouse-things to warehouse_things.
244
+ - The following tests from the ActiveRecord 2.1.0 test suite with ibm_db gem 0.10.0 are expected to fail on Informix Dynamic Server
245
+ - test_attributes_on_dummy_time
246
+ - test_quote
247
+ - test_read_attributes_before_type_cast_on_datetime
248
+ - test_save_for_record_with_only_primary_key
249
+ - test_save_for_record_with_only_primary_key_that_is_provided
250
+ - test_to_xml
251
+ - test_utc_as_time_zone
252
+ - test_should_calculate_grouped_by_function
253
+ - test_should_calculate_grouped_by_function_with_table_alias
254
+ - test_include_query
255
+ - test_binary_in_fixtures
256
+ - test_inserts_with_pre_and_suffix
257
+ - test_create
258
+ - test_add_column_with_precision_and_scale
259
+ - test_add_table_with_decimals
260
+ - test_native_types
261
+ - test_schema_dump_includes_decimal_options
262
+ - Usage with Rails-3.0.3/Rails-3.0.4
263
+ - To use with Rails-3.0.3/4 patch latest Arel with the patch available at https://gist.github.com/814491
264
+
265
+ Unicode Support
266
+ ===============
267
+ - Available only with Ruby version 1.9 and above
268
+ - Data returned from the driver will be in UTF8 encoding format.
269
+ - The input data to the driver can be in any Ruby supported encoding format.
270
+
271
+ To Do
272
+ ====
273
+ - Support ActiveRecord remove_column method for DB2 zOS version 9
274
+
275
+
276
+ Feedback
277
+ ========
278
+ Your feedback is very much appreciated and expected through Rubyforge:
279
+ - rubyibm project: http://rubyforge.org/projects/rubyibm/
280
+ - rubyibm forum: http://rubyforge.org/forum/?group_id=2361
281
+ - rubyibm bug reports: http://rubyforge.org/tracker/?group_id=2361
282
+ - IBM_DB developers: rubyibm-developers@rubyforge.org