[erlang-questions] learning mnesia:select syntax

Richard Andrews bbmaj7@REDACTED
Fri Oct 5 03:21:11 CEST 2007


--- Jani Launonen <launoja@REDACTED> wrote:
> Just try these and try making more compicated examples stepwisely. I  
> hope that helped.

That is exactly the approach that I took.

Example from the mnesia doc:

      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. I expect to
be able to make it return a tuple for each match but could not figure out how.
Nothing I read indicates that this can or cannot be done.

I ended up giving up and using match_object instead.



      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