Mnesia: table names vs record name

Klacke klacke@REDACTED
Wed Oct 27 10:40:17 CEST 1999


Emmanuelle BERNARD writes:
 > Hi,
 > 
 > I'd like to build several tables with the record "domain"
 > So I create my table as follows:
 >     TabDef=[{record_name,domain}]
 >     mnesia:create_table(school,TabDef).
 > 
 > But when I want to write a #domain Tuple in the database with the
 > write/3 function, the answer is "bad_type"
 > How to make a disc_copies of this table school?(it doesn't want me to
 > write anything else in the TabDef)

This works like a charm for me:

12> TabDef=[{record_name,domain}].
[{record_name,domain}]
13> mnesia:create_table(school,TabDef).
{atomic,ok}
14> mnesia:transaction(fun() ->mnesia:write(school, {domain, 3,4}, write) end).
{atomic,ok}

Maybe you are not having #domain record with exactly
two attributes. Since you are not specifying the attributes,
2 is the deafult:

mnesia:transaction(fun() ->mnesia:write(school, {domain, 3,4,5}, write) end).
{aborted,{bad_type,{domain,3,4,5}}}

Checkout the {attributes , A} flag to mnesia:create_table/2

 > 
 > moreover, I don't succeed in loading any textfile, there is an error in
 > the line 1 of my file, although I wrote exactly the same code provided
 > on www.erlang.org in Chapter 4.4 from the User's Guide for Mnesia...
 > 

Probably the same problem here ??

/klacke




More information about the erlang-questions mailing list