[erlang-questions] Mnemosyne query problem
Ulf Wiger (TN/EAB)
ulf.wiger@REDACTED
Fri Jan 11 16:36:09 CET 2008
One way to do this is to use the exprecs parse transform,
http://forum.trapexit.org/viewtopic.php?p=21790#21790
which would allow you to write:
Q = query
[ Entity
|| Entity <- table(TableName),
[AttributeValue] == M:'#get-'([AttributeName], Entity)
]
where M is some module in which you've declared and
exported the record definition of Entity.
(Not that I've tested this, but I believe it should work.
It's been a few years since I played with Mnemosyne
queries.)
BTW, for this type of query, you should really use QLC
instead, since Mnemosyne is no longer supported.
BR,
Ulf W
Matej Kosik skrev:
> -----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
More information about the erlang-questions
mailing list