<div dir="ltr">Hi Lloyd,<div><br></div><div>If you are not querying by the primary key, you should use mnesia:index_read/3 rather than mnesia:read/1</div><div><br></div><div>hth,</div><div>Chandru</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 September 2017 at 20:40, <span dir="ltr"><<a href="mailto:lloyd@writersglen.com" target="_blank">lloyd@writersglen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Life gets tricky in the literary world. Some authors use a pen name on their books rather than legal name. But it's quite possible for two different authors to use the same pen name. So pen name is not a good key to associate an author and a book. But ISBN does nicely.<br>
<br>
Email provides a convenient user name for access to a website. It minimizes the problem of two different people having the same user name.<br>
<br>
So in my user record I use email as the primary key. But, at creation of the record, I also generate a unique user_id in slot five in the user record. And I create an index to locate the user by user_id. This is handy, because I can use user_id to locate all of the user's books.<br>
<br>
So one would think that this query would work:<br>
<br>
get_member_by_member_id(<wbr>MemberID) when is_list(MemberID)-><br>
Query =<br>
fun() -><br>
mnesia:read({?TABLE, MemberID})<br>
end,<br>
{atomic, Results} = mnesia:transaction(Query),<br>
case length(Results) < 1 of<br>
true -> [];<br>
false -> hd(Results)<br>
end.<br>
<br>
But it doesn't. It returns an empty list.<br>
<br>
Not doubt I've forgotten something about mnesia or never learned it.<br>
<br>
Any help?<br>
<br>
Many thanks,<br>
<br>
LRP<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div><br></div>