Erlang Mailing Lists

Author Message

<  Erlang questions mailing list  ~  mnesia query for list membership?

edwiny at autonomy.com
Posted: Wed Dec 16, 1998 4:35 pm Reply with quote
Guest
Hello,

I tried the following, but I got an impenetrable error message (which I don't have with me: sorry).
Any suggestions?

-record(document, {id
title}).

docs(Term) ->
Fun = fun() ->
Q = query [ D.title || D <- table(document),
lists:member(1,[1]) ]
end,
mnemosyne:eval(Q)
end,
mnesia:transaction(Fun).

If I replace the list check with (say) D.id /= 0, it works fine. If I can't call standard functions inside
a query, how should I do this? Post-filter the result list?

Thanks a lot,

--
Edwin

PS Great language, BTW!



Post generated using Mail2Forum (http://m2f.sourceforge.net)
btu at erix.ericsson.se
Posted: Wed Dec 16, 1998 4:57 pm Reply with quote
Guest
On Wed, 16 Dec 1998, Edwin Young wrote:

> Hello,
>
> I tried the following, but I got an impenetrable error message (which I
> don't have with me: sorry).
> Any suggestions?
>
> -record(document, {id
> title}).

You do have a comma between id and title, don't you?

I tried your code (exact example attached) and it works
like a charm on the version I got here (which is very similar
to the open source that is released).

The shell output is as follows:

Erlang (JAM) emulator version 4.7.3.4

Eshell V4.7.3.4 (abort with ^G)
1> c(tst).
{ok,tst}
2> tst:s().
{atomic,ok}
3> tst:add(23,hello).
{atomic,ok}
4> tst:docs(2).
{atomic,[hello]}


// bjoern


--
Mouse moved last hour: 41.84, today: 364.28, this week: 627.84 (meters)


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum