[erlang-questions] learning mnesia:select syntax
Richard Andrews
bbmaj7@REDACTED
Sat Oct 6 03:36:04 CEST 2007
--- Håkan Huss <huss01@REDACTED> wrote:
> On 10/5/07, Richard Andrews <bbmaj7@REDACTED> wrote:
> >
> > MatchHead = #employee{name='$1', sex=male, room_no={'$2', '_'},
> _='_'},
> > Guard = [{'>=', '$2', 220},{'<', '$2', 230}],
> > Result = '$1',
> > mnesia:select(employee,[{MatchHead, Guard, [Result]}])
> >
> > I want to modify this to return {name, sex} of every employee with the same
> > Guard.
> >
> > MatchHead is easy change sex='$3'.
> >
> > Now what do I do with Result if I want to get back multiple fields.
>
> Result = {{'$1','$3'}},
>
> Perhaps not obvious, but read the match spec information in the ERTS user
> guide.
I did read that information in ERTS and came to the conclusion that it should
be
Result = {'$1', '$3'}
which didn't work. And the error message of course gave me no information about
how it was malformed.
I cannot tell you how many times I read the ERTS grammar and still didn't
notice the double braces in TermConstruct.
Thanks.
Sick of deleting your inbox? Yahoo!7 Mail has free unlimited storage.
http://au.docs.yahoo.com/mail/unlimitedstorage.html
More information about the erlang-questions
mailing list