I written the below code in common controller. I will pass the
model_name and it has to lock and unlock the table.
Please help me to correct this code...
def lock_table(model_name)
locked_table = model_name.find(:all, :lock => true)
return locked_table;
end
Thanks,
--
Posted via http://www.ruby-forum.com/.
That's not how it works. Behind the scenes, it will generate an SQL
statement: SELECT FOR UPDATE, if wrapped in a transaction, then it will
create a lock and then release it when transaction ends.
I'm new to ruby. Can u give me some example.
Hey, thanks to all...
My code is working..thanks....
ActiveRecord::Base.connection.execute('LOCK TABLES tablename WRITE')
ActiveRecord::Base.connection.execute('UNLOCK TABLES')
imagine you lock the tables.. and then you will be disconnected from the
session for some reason... tables are still locked, no way to work with
them. That's the point dbs have transations...
...
tom
--
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
===============================================================================