<div dir="ltr"><div>Sure, but who's to say get_note is intended as "just" a db interface function? That was my point in saying that it depends on the intended semantics of that function.The fact that he was considering giving the empty case an 'error' tag suggests that perhaps there's more to it. But there's not enough information in the original question to make a judgement either way.<br><br></div>B<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 8, 2016 at 1:21 PM, Sergej Jurečko <span dir="ltr"><<a href="mailto:sergej.jurecko@gmail.com" target="_blank">sergej.jurecko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I disagree. That kind of logic does not belong in a db interface function. </p><span class="HOEnZb"><font color="#888888">
<p dir="ltr">Sergej</p></font></span><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Feb 8, 2016 1:25 AM, "Bernard Duggan" <<a href="mailto:bernard@hippware.com" target="_blank">bernard@hippware.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>>An empty result to a db query is not an error.<br></div>That rather depends on the semantics of your program. In the general case, you're absolutely right, of course - that's why mnesia:read() doesn't return an error in that case. However, perhaps in the case of Lloyd's application, there should always be something in that particular table - maybe something populated at startup that nothing should ever delete. In that case it would be perfectly reasonable to not just produce an error, but in fact to crash.<br></div><div>So I guess what I'm saying is that my answer would be "it depends on what you want the semantics of get_note to be". Is it expected to always return one or more values? Is it an error if it doesn't, and if so, is that error sensibly recoverable by the caller?<br></div><div><br></div>Cheers,<br><br></div>B<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 8, 2016 at 5:45 AM, Sergej Jurečko <span dir="ltr"><<a href="mailto:sergej.jurecko@gmail.com" target="_blank">sergej.jurecko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">An empty result to a db query is not an error.</p><span><font color="#888888">
<p dir="ltr">Sergej</p></font></span><div><div>
<div class="gmail_quote">On Feb 7, 2016 7:38 PM,  <<a href="mailto:lloyd@writersglen.com" target="_blank">lloyd@writersglen.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have this mnesia query:<br>
<br>
<br>
get_note(ID) -><br>
    Query =<br>
        fun() -><br>
            mnesia:read({?TABLE, ID})<br>
        end,<br>
    {atomic, Results} = mnesia:transaction(Query),<br>
    Results.<br>
<br>
It returns either a list containing one or more valid records or an empty list.<br>
<br>
Would it be better to return something like:<br>
<br>
{ok, Records} | {error, data_not_found}<br>
<br>
Thanks,<br>
<br>
LRP<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div>
</div></div></blockquote></div><br></div>