我有一个有这个记录的表人:
-record(person, {id, firstname, lastname, address}).
我想开发一个函数来检索这个表的最后一个 id
我尝试使用此功能:
get_userId() ->
Q = qlc:q([{X#person.id} || X <- mnesia:table(person)
]),
case do(Q) of
[{H}] ->
{ok, H};
[] ->
{error, notfound}
end.
我用这段代码做测试
test()->
case get_userId() of
{ok, H}->io:format("~s~n",[H]);
[] ->
{error, notfound}
end.
但是当我进行测试时出现错误
2> model:test().
** exception error: no case clause matching [{238},
{82},
{76},
{257},
{141},
{2},
{315},
{336},
{275},
{88},
{326},
{211},
{81},
{333},
{351},
{214},
{64},
{265},
{210},
{90},
{302},
{98},
{212},
{197},
{194},
{132},
{226},
{3},
{...}|...]
in function model:get_userId/0
in call from model:test/0