[erlang-questions] Mnemosyne query problem

Andy Gross andy@REDACTED
Fri Jan 11 16:33:23 CET 2008


Matej,

mnemosyne (AFAIK) is deprecated and unmaintained.  Check out QLC  
(query list comprehensions):  http://erlang.org/doc/man/qlc.html

- Andy



On Jan 11, 2008, at 10:12 AM, Matej Kosik wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Friends,
>
> I would like to perform the following query:
>
>    TableName = circuit,
>    AttributeValue = ipe_od,
>    AttributeName = type,
>    F = fun() ->
>         Q = query
>            [  Entity
>            || Entity <- table(TableName),
>               Entity.AttributeName=AttributeValue
>            ]
>         end,
>         mnemosyne:eval(Q)
>    end,
>    {atomic, Entities} = mnesia:transaction(F).
>
> Unfortunatelly, compilator rejects its. I would like to write a code  
> that selects particular
> entities from a given TableName whose AttributeName has a given  
> AttributeValue.
>
> Since Erlang does not accept bound variables here
>
> 	Entity.AttributeName=AttributeValue
>
> I must literally hard-wire particular attribute name. For example
>
> 	Entity.od_id=AttributeValue
>
> (here `od_id' means id of octal-demodulator). This way I would have  
> to write such code for every
> kind of Mnesia table and for every attribute name. That is possible  
> but does not makes sense.
>
> The immediate hack is to load all entities into the memory and make  
> ordinary list-comprehension. It
> might work, as long as things fit into memory (and some other things  
> in VM do not overflow). But how
> to actually write a code that works as the original (non-compilable)  
> piece was supposed to work?
>
> Thanks in advance
> - --
> Matej Kosik
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHh4dVL+CaXfJI/hgRAisKAKDXDWxoIbO9WP+jDqO5UQMXJiVLhQCgpklI
> iYolHdgQ/8A3dpAfl0FoNak=
> =/v97
> -----END PGP SIGNATURE-----
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list