<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: transaction code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 23:48:53 GMT</pubDate>
    <description>DZone Snippets: transaction code</description>
    <item>
      <title>SQL Transaction in Rails</title>
      <link>http://snippets.dzone.com/posts/show/3995</link>
      <description>&lt;code&gt;&lt;br /&gt;def fetch_value&lt;br /&gt;	sql = ActiveRecord::Base.connection();&lt;br /&gt;	sql.execute "SET autocommit=0";&lt;br /&gt;	sql.begin_db_transaction&lt;br /&gt;	id, value =&lt;br /&gt;	sql.execute("SELECT id, value FROM sometable WHERE used=0 LIMIT 1 FOR UPDATE").fetch_row;&lt;br /&gt;	sql.update "UPDATE sometable SET used=1 WHERE id=#{id}";&lt;br /&gt;	sql.commit_db_transaction&lt;br /&gt; &lt;br /&gt;	value;&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 11 May 2007 18:44:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3995</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
  </channel>
</rss>
