在用 SQLAnywhere 连接 Sybase IQ,有以下程序:
def db_query( dbh, sql )
sth = dbh.execute(sql)
print "# of Fields: #{sth.column_names.size}\n"
sth.fetch do |row|
print "\n"
sth.column_info.each_with_index do |info, i|
unless info["type_name"] == "LONG VARBINARY"
print "#{info["name"]}=#{row[i]}\n"
end
end
end
sth.finish
end
程序的完整地址:http://dcx.sap.com/sa160/fr/dbprogramming/pg-ruby-dbi.html 调用改程序进行查询,出现错误:
/home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/columninfo.rb:49:in `[]=': can't add a new key into hash during iteration (RuntimeError)
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/columninfo.rb:49:in `block in initialize'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/columninfo.rb:42:in `each_key'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/columninfo.rb:42:in `initialize'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:185:in `new'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:185:in `block in column_info'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:185:in `collect'
from /home/sybase/.gem/ruby/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:185:in `column_info'
from Conn2IQ3.rb:29:in `db_select'
from Conn2IQ3.rb:59:in `<main>'
这是什么原因?