1
votes

Using following method I have tried to create a table,

mnesia_init() -> 
mnesia:create_schema([node()]),
case mnesia:start() of
    ok ->
        try
            mnesia:table_info(type, bill_cdr_file_counter)
        catch 
            exit:_ ->
                mnesia:create_table(bill_cdr_file_counter,[{attributes,[key,value]},
                                                           {disc_copies,[node()]}])
        end;
    {error, Reason} ->
        error_logger:error_report(["Mnesia start error: ", Reason]),
        {error, Reason}
end.

the record I have used is the following,

-record(bill_cdr_file_counter, {key,value}).

but as response I'm getting this,

{aborted,{bad_type,bill_cdr_file_counter,{disc_copies,log@mbsmsc1}}}
1

1 Answers

1
votes

Your code works fine for me. The first time I run it I get the return value:

{atomic,ok}

The second time I run it, I get the return value:

{aborted,{already_exists,bill_cdr_file_counter}}

And when I do:

4> observer:start() 

then click on the Table View tab, then in the menu bar select View>Mnesia Tables, I see the bill_cdr_file_counter table listed. I'm using Erlang 19.2. What version of Erlang are you using?

I also tried:

3> node().
nonode@nohost

Or, if I start erl like this:

$ erl -sname gandalf

1> node().
gandalf@MyMBP

You're error message says that node() is returning:

log@mbsmsc1

That's the only difference I see between your code and the code I ran.