2013-02-22 85 views
0

每個記錄顯示信息,我有這個表:在二郎

-record(person, {id, firstname, lastname}). 

,它包含此值:

13 asma chabani 
14 nawel jirard 
15 ahme bahri 

我要顯示的每個記錄的名字和姓氏:

我嘗試:

test()-> 
    Match=#person{_ = '_'}, %Will match all records 
    Fun = 
     fun() -> 
     List = mnesia:match_object(Match), 
     lists:foreach(fun(X) -> 
         M=X#person.fistname, 
         H=X#person.lastname, 
         io:format("~s~n",[M]), 
         io:format("~s~n",[H]) 
         end, 
         List) 
     end. 

但它顯示此錯誤:

model:test(). 
#Fun<model.186.53419390> 
+2

'#Fun ' - 這不是錯誤,這是你定義的函數'Fun = fun()...' – 2013-02-22 10:49:22

回答

2

你忘了mnesia:transaction(Fun)到底?或者只是有趣()。

+0

是的,謝謝你的回答 – 2013-02-22 14:43:04