dear all, I''m a Rails newbie and i have some problem. I''m using MySQL. I want to excute some complexity query, and I need to create some table to hold temp query result. I want to know how to execute some SQL query such like "CREATE TEMPORARY TABLE templist SELECT * FROM table2 " I''ve tried to excute find_by_sql("create table templist select * ...), but it seem to return a nil object , so that rails will halt. any tips is appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I won''t hold you back, but perhaps you should think about you solution - temp tables are always strange.. Anyways, http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M000728 ActiveRecord::Base.execute(sql, name=nil) is your friend. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Florian Gilcher wrote:> I won''t hold you back, but perhaps you should think about you solution - > temp tables are always strange.. Anyways, > > http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M000728 > > ActiveRecord::Base.execute(sql, name=nil) > > is your friend.thanks. and I find "execute" in my "Agile" book. However, I still don''t know how to "execute" it in my controller. if I add this line: List.execute ("drop table if exists testtable;") then i got a error: "NoMethodError in LookupController#findcross undefined method `execute'' for List:Class" Any tips is appreciated. -Feng -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
feng wrote the following on 06.04.2007 15:25 :> Florian Gilcher wrote: > >> I won''t hold you back, but perhaps you should think about you solution - >> temp tables are always strange.. Anyways, >> >> http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M000728 >> >> ActiveRecord::Base.execute(sql, name=nil) >> >> is your friend. >> > > thanks. and I find "execute" in my "Agile" book. > > However, I still don''t know how to "execute" it in my controller. > > if I add this line: > > List.execute ("drop table if exists testtable;") >List.connection.execute should do it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lionel Bouton wrote:> feng wrote the following on 06.04.2007 15:25 : >>> >> >> thanks. and I find "execute" in my "Agile" book. >> >> However, I still don''t know how to "execute" it in my controller. >> >> if I add this line: >> >> List.execute ("drop table if exists testtable;") >> > > List.connection.execute should do it.it works! thanks very very much ! :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---