<div dir="ltr">If there are 0 records in the pw_usr_record table, the wread will return [], not [Usr], so your transaction will fail due to case_clause.<div><br></div><div>Or am I missing something?</div><div><br></div><div>Cheers,</div><div>Daniel</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 25 Jan 2021 at 03:57, Peter J Etheridge <<a href="mailto:petergi@iinet.net.au">petergi@iinet.net.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px"><div>Dear Fellow Erlangers,</div><div><br></div><div>I run;</div><div><br></div><div>mnesia:transaction(fun() -><br> case mnesia:wread({pw_usr_record, pw_un}) of<br> [Usr] -><br> Usr = #pw_usr_record{pw_un = Username, pw_pas = Password},<br> mnesia:write(pw_usr_record, Usr, write),<br> catch mnesia:abort("aborted")<br> end<br> end),</div><div><br></div><div>result;</div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">mnesia:info().
</span><br>---> Processes holding locks <--- <br>---> Processes waiting for locks <--- <br>---> Participant transactions <--- <br>---> Coordinator transactions <---
<br>---> Uncertain transactions <--- <br>---> Active tables <--- <br>pw_usr_record : with 0 records occupying 305 words of mem
<br>schema : with 2 records occupying 533 words of mem
<br>===> System info in version "4.17", debug level = verbose <===
<br>opt_disc. Directory "/home/kanga/Documents/ebin/include/priv/src/Mnesia.nonode@nohost" is used.
<br>use fallback at restart = false
<br>running db nodes = [nonode@nohost]
<br>stopped db nodes = [] <br>master node tables = []
<br>remote = []
<br>ram_copies = [pw_usr_record]
<br>disc_copies = [schema]
<br>disc_only_copies = []
<br>[{nonode@nohost,disc_copies}] = [schema]
<br>[{nonode@nohost,ram_copies}] = [pw_usr_record]
<br>3 transactions committed, 1 aborted, 0 restarted, 2 logged to disc
<br>0 held locks, 0 in queue; 0 local transactions, 0 remote
<br>0 transactions waits for other nodes: []
<br>ok<br><br>As shown above, instead of writing (0 records shown) the transaction is aborting (1 aborted).</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Could the Variable be out of scope?</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Where else might I look?</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Thank you in advance,</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Peter<br></span></div><div><br></div><div><br></div><br><br></div>
</blockquote></div>