insert a record

Ulf Wiger (AL/EAB) <>
Wed May 18 14:19:26 CEST 2005


Hi!

The index is transparent to insert operations.
Mnesia maintains the indexes behind the scenes, and you
never have to specify indexes except (a) when you create
the table and (b) when you specifically want to use the 
index to locate data in your table.

Put another way, there is no way you CAN specify the index
during insert. You are not allowed to mess with the updating
of indexes, since this can lead to inconsistencies(*).

/Uffe

(*) Well, there is one way: you can do an (d)ets:insert directly
into the physical table, or use mnesia:activity(ets, fun() ...).
If you do this on a table that has indexes specified, you are 
practically guaranteed to mess up your database! The same thing
goes for replicated tables.

> -----Original Message-----
> From: 
> [mailto:]On Behalf Of 
> Dietmar Schaefer
> Sent: den 18 maj 2005 07:45
> To: Erlang Questions
> Subject: insert a record 
> 
> 
> Hi !
> 
> Is there a way of inserting a record into a database without 
> specifying 
> the index ?
> 
> What I have is :
> 
>  mnesia:create_table(centerDisplayProcessesList, [{snmp, 
> [{key, integer}]},
>                               {attributes, record_info(fields, 
> centerDisplayProcessesList)},
>                               {disc_copies, Nodes}]) of
> 
> So I have a integer (snmp) index.
> 
> Now I would be able to just insert a new record for which I 
> do not care 
> about the
> index.
> 
> Index must be in the range (1..40) but should be supplied 
> automatically !
> 
> 
> regards
> 
> 
> Dietmar
> 
> 
> 



More information about the erlang-questions mailing list