mnesia:clear_table

Serge Aleynikov <>
Mon Aug 15 22:05:31 CEST 2005


Hi,

I am wondering why the mnesia:clear_table/1 function is encapsulated in 
a transaction of its own.  It prevents this function to be included in 
another transaction.

I need to clear the table and populated it within a single transaction. 
  Is there a way to do that other than iterating though all records in 
the table?

F() ->
    mnesia:write_lock_table(Tab),

    % Delete records
    Keys = mnesia:all_keys(Tab),
    [mnesia:delete(Tab, Key) || Key <- Keys],

    % Insert records
    [mnesia:write(Tab, R) || R <- Data]
end,
mnesia:transaction(F).

Thanks,

-- 
Serge Aleynikov
R&D Telecom, IDT Corp.
Tel: (973) 438-3436
Fax: (973) 438-1464




More information about the erlang-questions mailing list