From: Hans Meier Date: 2007-08-01T19:01:46+09:00 Subject: Re: parse xml file, put results in mysql db Alex Gutteridge wrote: > On 1 Aug 2007, at 17:12, Hans Meier wrote: > >> mobils.elements.each("MobileDevices/MobileDevice") { |element| >> puts >> models.each_index do |index| >> from /usr/local/lib/ruby/site_ruby/1.8/dbi/sql.rb:192:in >> `each_index' >> from >> ./script/../config/../config/../lib/rails_maintainer.rb:53:in >> `importContentDelivery' >> from (irb):1 > > This line: > >> sth=dbh.prepare("INSERT INTO mobil_devices (model, manufacturer, >> mobil_device_id,) >> VALUES (?,?,?)") > > prepares an SQL statement expecting three values (model > manufacturer,mobil_device_id). > > This line: > >> sth.execute("mobils.xml", "abo_development", "#{model}", >> "#{manufacturer}", "#{mobil_device_id}") > > attempts to execute the SQL with 5 values ("mobils.xml", > "abo_development", model, manufacturer, mobil_device_id). Hence the > complaint: > >> RuntimeError: Too many SQL parameters > > Alex Gutteridge > > Bioinformatics Center > Kyoto University Ok, thank you. I found the failure, but get a new failure: DBI::DatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('735i','Alcatel','1133')' at line 1 from /usr/local/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:115:in `error' from /usr/local/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:579:in `execute' from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:617:in `execute' from ./script/../config/../config/../lib/rails_maintainer.rb:58:in `importContentDelivery' from ./script/../config/../config/../lib/rails_maintainer.rb:54:in `each_index' from ./script/../config/../config/../lib/rails_maintainer.rb:54:in `importContentDelivery' from (irb):2 -- Posted via http://www.ruby-forum.com/.