Mnesia question
Hakan Mattsson
hakan@REDACTED
Mon Apr 26 09:00:05 CEST 1999
mikl>I suspect a misconfiguration, but I did not see what I a missing.
I think that you forgot to start the mnemosyne application.
The attached example worked for me, when Mnemosyne was started.
~> erl
Erlang (BEAM) emulator version 4.8.1
Eshell V4.8.1 (abort with ^G)
1> c(memo().
** 1: syntax error before: '.' **
1> c(memo).
./memo.erl:27: Warning: non-recommended option 'export_all' used
{ok,memo}
2> memo:init().
ok
3> memo:task(hakan).
{atomic,[{tasks,drink_coffee,hakan}]}
4> application:stop(mnemosyne).
=INFO REPORT==== 26-Apr-1999::08:54:17 ===
application: mnemosyne
exited: stopped
type: temporary
ok
5> memo:task(hakan).
=ERROR REPORT==== 26-Apr-1999::08:54:19 ===
<0.25.0> error: nocatch in mnemosyne_lc:the_query/1
** exited: nocatch **
Regards
Håkan
-------------------------------------+------------------------------------
Håkan Mattsson, | +46 8 719 9452
Computer Science Laboratory | hakan@REDACTED
Ericsson Network Core Products | http://www.ericsson.se/cslab/~hakan
Box 1505, SE-126 25 Stockholm Sweden |
-------------- next part --------------
-module(memo).
-author('hakan@REDACTED').
-compile([export_all, {parse_transform, mnemosyne}]).
-record(tasks, {id, user_id}).
-record(users, {id, phone}).
init() ->
ok = application:start(mnesia),
ok = application:start(mnemosyne),
{atomic, ok} = mnesia:create_table(tasks, [{attributes, [id, user_id]}]),
{atomic, ok} = mnesia:create_table(users, [{attributes, [id, phone]}]),
ok = mnesia:dirty_write(users, #users{id = hakan, phone = 99251}),
ok = mnesia:dirty_write(tasks, #tasks{id = drink_coffee, user_id = hakan}).
task(User) ->
Q = query
[ T ||
T <- table(tasks),
U <- table(users),
U.id = User,
T.user_id = U.id ]
end,
F = fun() -> mnemosyne:eval(Q) end,
mnesia:transaction(F).
More information about the erlang-questions
mailing list