mnesia db dir

Róbert Balogh (IJ/ETH) robert.balogh@REDACTED
Sun Jul 10 15:31:10 CEST 2005


Hej mnesia experts,

I'm a beginner in mnesia and I have some questions about mnesia. Sorry but I couldn't find the answer for these in the mnesia doc :-(

The first question is it possible to set the path of the mnesia db from "code". I mean is there other way than erl -sname nodename -mnesia dir '"dirpath"'?

I wrote a small code for learning mnesia and I take a big "discovery". It's not possible to insert any record in the table, if the table name is different that the name of his record. 
Here is my example:

-module(ex_mnesia).

-export([start/0]).

-export([insert/1]).

-record(rPerson,{name = [],
                city = []}).


start()->
    mnesia:create_schema([node()]),
    mnesia:start(),
    mnesia:create_table(table,[{attributes,record_info(fields,rPerson)},
                                {disc_copies,[node()]}]).
    

insert(Value)->
    Fun = fun()->
            mnesia:write(table,#rPerson{name = Value},write)
          end,
    mnesia:transaction(Fun).

After calling insert I got this in the erlang shell:
(a@REDACTED)5> ex_mnesia:insert(aa).
{aborted,{bad_type,{rPerson,aa,[]}}}

If I change the name of table to rPerson it's possible to insert records in the table. So is that true that no way to set different name the table as his record name or I did something wrong?

Here is what I got after change table name:
(a@REDACTED)3> ex_mnesia:insert(aa).
{atomic,ok}


thanks a lot the answers,

br,
/Robi






More information about the erlang-questions mailing list