I wanted to make sure there was still no way to tell Mnesia to return an error if it is given a record to write that has the same key as an object already stored in the table.<div><br></div><div>Reading through the docs it looks like there is no way through configuration but you must simply read and then write if its not there, like I found when this was asked in 2004 on this mailing list: </div>
<div><br></div><div><div>insert(K,V) -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>fun() -></div><div> <span class="Apple-tab-span" style="white-space:pre">         </span>case mnesia:wread(K) of</div>
<div> <span class="Apple-tab-span" style="white-space:pre">             </span>  [Exist] -> {abort, Exist};</div><div> <span class="Apple-tab-span" style="white-space:pre">             </span>  _ -> mnesia:write(V)</div><div> <span class="Apple-tab-span" style="white-space:pre">           </span>end</div>
<div> <span class="Apple-tab-span" style="white-space:pre">     </span>end.</div></div><div><br></div><div>Which doesn't seem safe, as Ulf points on in that thread: <a href="http://erlang.org/pipermail/erlang-questions/2004-May/012307.html">http://erlang.org/pipermail/erlang-questions/2004-May/012307.html</a></div>
<div><br></div><div>As well as slow.</div><div><br></div><div>So I was hoping maybe in 2011 there is a better way to do this? :)</div><div><br></div><div>Thanks,</div><div>Tristan</div>