Please help me to write an alternative code for below in ROR... ActiveRecord::Base.connection.execute("LOCK TABLES table_name WRITE") ActiveRecord::Base.connection.execute(''UNLOCK TABLES'') Regards, -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-May-19 07:26 UTC
Re: Lock Table : Help me to write an alternative code in RoR
On May 19, 6:51 am, Venkat Eee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Please help me to write an alternative code for below in ROR... >There''s nothing built into rails as far as table locks go, so there''s not much more that you can do than that (apart I suppose from wrapping things up nicely so that you can''t forget to unlock tables). Fred> ActiveRecord::Base.connection.execute("LOCK TABLES table_name WRITE") > ActiveRecord::Base.connection.execute(''UNLOCK TABLES'') > > Regards, > -- > Posted viahttp://www.ruby-forum.com/.
Conrad Taylor
2009-May-19 07:26 UTC
Re: Lock Table : Help me to write an alternative code in RoR
On Mon, May 18, 2009 at 10:51 PM, Venkat Eee < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Please help me to write an alternative code for below in ROR... > > ActiveRecord::Base.connection.execute("LOCK TABLES table_name WRITE") > ActiveRecord::Base.connection.execute(''UNLOCK TABLES'')Venkat, what are you trying to do exactly? It seems that you''re trying to do the following: a) lock the table b) do some db modifications c) unlock the table If this is the case, I would recommend reading up on the transaction support within RoR. If this doesn''t do the job for you, you may consider wrapping these methods in before and after filters respectively at the controller or model level. Good luck, -Conrad> > > Regards, > -- > 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 -~----------~----~----~----~------~----~------~--~---