【问题标题】:display information of each records in erlang在erlang中显示每条记录的信息
【发布时间】:2013-02-22 20:53:46
【问题描述】:

我有这张桌子:

-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>

【问题讨论】:

  • #Fun&lt;model.186.53419390&gt; - 这不是错误,这是您定义的函数Fun = fun()...

标签: erlang mnesia


【解决方案1】:

你最后忘记了mnesia:transaction(Fun)吗?或者只是 Fun()。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-07
    • 2017-11-04
    • 2012-10-25
    • 1970-01-01
    • 2020-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多