[erlang-questions] Can't fill in the mnesia table

Abhishek Ranjan abhishek@REDACTED
Mon Jul 10 09:42:55 CEST 2017


I wrote this code snippet:

Player=t:user(List),
CatchAll=[{'_',[],['$_']}],
NameList=mnesia:dirty_select(player, CatchAll),
if
(length(NameList)<4)->
T3 = fun() ->
X3 = #player{name=Player
},
mnesia:write(X3)
end,
mnesia:transaction(T3),
NameList1=mnesia:dirty_select(player, CatchAll),
?io:format("1The value of NameList1 is ~p~n",[NameList1]),
ok;
(length(NameList)==4)->
?io:format("2The value of NameList is ~p~n",[NameList])
end,       

Here, each time a call a module t:user I get a name which i have stored in Player and want to keep storing these names till there are 4 of them but each i time I run this I get an empty value of Namelist as [], instead of a list filled with players name.

Any Idea on why this is happening?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170710/4886df93/attachment.htm>


More information about the erlang-questions mailing list