[erlang-questions] export record to mnesia module
Peter J Etheridge
petergi@REDACTED
Sun May 12 07:05:11 CEST 2019
Dear Friends,
Un & Pw are captured in a record Usr from a wx module.
Usr is to be stored in mnesia in module(usrdb).
export_fun() does not trouble Dialyzer. Mnesia starts, but does not
create a new record;
export_fun(Pw, Un, Pwv, Unv, Usr) ->
case wxPasswordEntryDialog:connect(Pw, command_button_clicked,
[{userData, Pwv}]) of
ok ->
case wxTextEntryDialog:connect(Un, command_button_clicked,
[{userData, Unv}]) of
ok ->
register(usrdb, spawn_link(usrdb, handle_cast, [Usr])),
usrdb ! {send, Usr},
F = fun() ->
receive
Usr = #usr_record{un = Unv, pas = Pwv} ->
mnesia:write(usr_table, Usr, write)
after 0 ->
receive
Any ->
Any
end
end
end,
mnesia:transaction(F)
end
end,
export_fun(Pw, Un, Pwv, Unv, Usr).
What does this code lack?
Thank you in advance,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190512/25ea10af/attachment.htm>
More information about the erlang-questions
mailing list