Is there any way of executing a full sql script, and not just one statement? You can do this: ActiveRecord::Base.connection.execute("insert into batches (name) values ''name''") but not this: ActiveRecord::Base.connection.execute("insert into batches (name) values ''name''; "insert into batches (name) values ''name2'';"") -- Posted via http://www.ruby-forum.com/.
Nick Stuart
2006-May-09 13:35 UTC
[Rails] "ActiveRecord::Base.connection.execute" nubee problem
How about.... statements.split(";").each do |statement| ActiveRecord::Base.connection.execute(statement) end On 5/9/06, Abe <AbeyTom@hotmail.com> wrote:> > Is there any way of executing a full sql script, and not just one > statement? > > You can do this: > > ActiveRecord::Base.connection.execute("insert into batches (name) values > ''name''") > > but not this: > > ActiveRecord::Base.connection.execute("insert into batches (name) values > ''name''; "insert into batches (name) values ''name2'';"") > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060509/9dfe1d2b/attachment.html
Abe
2006-May-09 14:23 UTC
[Rails] Re: "ActiveRecord::Base.connection.execute" nubee problem
No, i WANT to send in all my statements at once for quicker execution. Is this possible? -- Posted via http://www.ruby-forum.com/.
Lionel Bouton
2006-May-09 22:36 UTC
[Rails] Re: "ActiveRecord::Base.connection.execute" nubee problem
Abe wrote the following on 09.05.2006 16:23 :> No, i WANT to send in all my statements at once for quicker execution. > Is this possible? > >I may be wrong but it seems to me that the difference should be unnoticeable as you are using the same connection (the only additional delay should be the network or system latencies between your client and the server). I''m wondering if the command-line SQL clients actually send a single string to execute or instead split them before execution (the servers might not support a single semicolon delimited string). Lionel.