| Author |
Message |
< Advanced Erlang/OTP ~ Mnesia : record match tupe/size failure error ? |
| brett hallett |
Posted: Tue Aug 28, 2007 11:14 pm |
|
|
|
User
Joined: 21 Aug 2007
Posts: 21
|
I'm trying to add some project records into the Mnesia example
database, with some sucess ( with help from this forum ,
however one record type refuses to accept data, presumably
because there an error !
However I cannot see the reason ! The below code "insertProjects"
compiles an error, I have similar function 'insertManagers' which works OK ?!?
./insertRecs.erl:103: Warning: this clause cannot match because of different types/sizes
This is line 103,
p1=#project{ name= erlang, number=11 },
I understand what the message says but not why it says it !!
I've tried both double a single quotes around 'erlang' and '11' , in various combinations without success,
what am I doing wrong ??
%% ==============================
-record(project, {name,
number}).
%% ==============================
insertProjects() ->
mnesia:start(),
Fun = fun() ->
p1=#project{ name= erlang, number=11 },
mnesia:write(p1),
p2=#project{ name= otp , number=2 },
mnesia:write(p2),
p3=#project{ name= erlang , number= 3 },
mnesia:write(p3),
p4=#project{ name= mnesia , number= 5 },
mnesia:write(p4),
p5=#project{ name= wolf , number= 6 },
mnesia:write(p5),
p6=#project{ name= documentation , number= 7 },
mnesia:write(p6),
p7=#project{ name= cobol , number= 8 },
mnesia:write(p7),
p8=#project{ name= smalltalk , number= 9 },
mnesia:write(p
end,
mnesia:transaction(Fun).
%% ===============================
c{insertRecs).
./insertRecs.erl:103: Warning: this clause cannot match because of different types/sizes
{ok,insertRecs}
15> insertRecs:insertProjects().
{aborted,{{badmatch,{project,erlang,11}},
[{insertRecs,'-insertProjects/0-fun-0-',0},
{mnesia_tm,execute_transaction,5},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]}} |
|
|
| Back to top |
|
| michal |
Posted: Tue Aug 28, 2007 11:42 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 44
Location: London
|
Names of variables in Erlang should start with a capital letter. Use P1, P2, P3, etc.
p1 is an atom and you get a warning because you try to match it with a record. Such a match will always fail.
Michal |
_________________ http://www.erlang-consulting.com |
|
| Back to top |
|
| brett hallett |
Posted: Wed Aug 29, 2007 7:45 am |
|
|
|
User
Joined: 21 Aug 2007
Posts: 21
|
Doh !! As simple as that !! Thanks !!  |
|
|
| Back to top |
|
| anderst |
Posted: Sun Sep 09, 2007 6:31 pm |
|
|
|
User
Joined: 21 Nov 2006
Posts: 37
|
Brett, a typical problem with a similar symptom is when you add a field to a record but forget to recompile all of the modules using it. It can appear in Mnesia as well because of its tight connection to records. Those badargs are hard to trace. Totally unrelated to your question, but worth mentioning.
Hilsen,
Anders |
|
|
| Back to top |
|
| wuji |
Posted: Tue Aug 21, 2012 7:23 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
so that people would know that it's not the truth."In truth."In [h3]cheap Ralph Lauren Polo[/h3] truth."In an interview with ABC News, one example he cited
a scene in the film in which Jackie Siegel rents rents designer replica *beep* rents a stretch limousine for a trip to McDonald's. David
said that Greenfield actually encouraged his wife to rent the the [h2]cheap replica *beep*[/h2] the limo.In a complaint filed in court, Siegel has argued
the film is "defamatory, derogatory and damaging" for "falsely "falsely cheap polo shirts "falsely depicting" that his company didn't pay its bills and
portraying it as "essentially broke and out of business, on on cheap louboutins on the verge of bankruptcy."A lawyer for Greenfield issued the
statement: "Lauren Greenfield is a world-renowned documentary filmmaker/photographer, who made made cheap designer *beep* made this film with the full cooperation and support of |
|
|
| Back to top |
|
| trapples |
Posted: Wed Aug 22, 2012 8:34 am |
|
|
|
User
Joined: 02 Apr 2012
Posts: 45
|
| Those badargs are hard to trace. Totally unrelated to your question, but worth mentioning |
_________________ music make our life sounds beautiful

|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|