From: edk_ruby@... (Edward Kremer) Date: 2002-03-04T13:37:20+09:00 Subject: DBI ODBC connection on WIN NT has a bug. DBI ODBC connection on WIN NT has a bug. Program access_odbc.rb: require 'dbi' URL = 'DBI:ODBC:expenses' dbh = DBI.connect(URL, "", "") sth = dbh.prepare('select * from employees') sth.execute while row = sth.fetch do p row end dbh.disconnect produces the following output >ruby access_odbc.rb /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `[]': no implicit conversion from string (TypeError) from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `column_names' from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `collect' from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `each' from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `collect' from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:714:in `column_names' from /cygdrive/e/ruby/lib/ruby/site_ruby/1.6/dbi/dbi.rb:695:in `execute' from access_odbc.rb:5 >Exit code: 1 Bug is actually found in the ODBC.rb in the following procedure: def column_info info = [] @handle.columns do |col| info << { 'name' => col.name, 'table' => col.table, 'nullable' => col.nullable, 'searchable' => col.searchable, 'precision' => col.precision, 'scale' => col.scale, 'sql_type' => col.type, 'type_name' => DBI::SQL_TYPE_NAMES[col.type], 'length' => col.length, 'unsigned' => col.unsigned } end rescue ODBCErr => err raise DBI::DatabaseError.new(err.message) end This procedure is supposed to return info that is array of hashes but returns some intermediate result. To fix bug you can insert a single line of code before “rescue” line. Additional line will be, of course: info This solves the problem and now program produces correct output: >ruby access_odbc.rb [12, "890340376", "4356", "Jim", "Pope", "Mr", "3456", "77 Southstreet,", "Phila", "PA", "19307", "USA", "213-241-8833", nil] >Exit code: 0 Actually I am new user of ruby in the following environment: WINDOWS NT RUBY cygwin installation from PragmaticProgrammers site, version 1.6.5 (2001-09-19) [i386-cygwin] This installation is missing database drivers, in particularly, ODBC.so Oracle.so I downloaded version of odbc.so compiled at 10/11/2001from http://www.ch-werner.de/rubyodbc/ and now it is working. I tested it for Ms Access and ORACLE – ODBC connections. I got a feeling that oracle-odbc connection is relatively slow compared to the similar Perl connection, so it would be desirable to check how the native connection works. I am wondering if anybody can share oracle.so driver for described environment? (Oracle8i Enterprise Edition Release 8.1.6.0.0) I do not have currently C compiler on the machine where ORACLE is installed. Thanks a lot, Edward Kremer