I need to do a multiple insertion in the database.It shows me an error all the time
Single insertion works perfect:
CONN = ActiveRecord::Base.connection
irb(main):271:0> inserts.push'(1,2,3,4,5,6)'
=> ["(1,2,3,4,5,6)"]
sql="INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES #{inserts.join(", ")}"
irb(main):276:0> CONN.execute sql
(32.3ms) INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES (1,2,3,4,5,6)
=> []
Multiple insertions do not work at all:
irb(main):272:0> inserts.push'(7,8,9,10,11,12)'
=> ["(1,2,3,4,5,6)", "(7,8,9,10,11,12)"]
irb(main):278:0>sql="INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES #{inserts.join(", ")}"
=> "INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES (1,2,3,4,5,6), (7,8,9,10,11,12)"
irb(main):279:0> CONN.execute sql
(0.4ms) INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES (1,2,3,4,5,6), (7,8,9,10,11,12)
ActiveRecord::StatementInvalid: SQLite3::SQLException: near ",": syntax error: INSERT INTO signals_rmas (groupsnorm_id, arraydb_id, probeset_id,signal,updated_at,created_at) VALUES (1,2,3,4,5,6), (7,8,9,10,11,12)
What is the problem? How can I insert multiple records as a time in sql?(create record) Thanks in advance