mnesia key of last inserted record

Roberto Saccon rsaccon@REDACTED
Mon Jun 26 04:23:33 CEST 2006


Uuff, I "assumed"  the key is not part of the provided record  and
autoincremented by mnesia. But now everything is clarified, thanks.

On 6/25/06, Ryan Rawson <ryanobjc@REDACTED> wrote:
> Since mnesia doesn't support 'auto increment' the last key is whatever
> it was you chose!  Meaning that the first field in your tuple is the
> key of the record, thus whatever it is you had it set to is what it
> is.  If you want to support sequences, you need to do a seperate
> sequence fetch in your own code, and thus know what the artifical key
> would be.
>
> Specifically you would have code like:
>
> Record=#myRec{a=1,b=2,c=3} ,
> mnesia:write(Record) ,
> %%% what is the key? Well the key is '1' since a=1
>
> -ryan
>
> On 6/25/06, Roberto Saccon <rsaccon@REDACTED> wrote:
> > How can I get the key of the last inserted record at mensia ? Right
> > after mnesia:write I need to know the key. I think  could construct
> > something with mnesia:match_object() to retrieve that key, but there
> > must must be something smarter and with less overhead to get that key
> > !
> >
> > regards
> > --
> > Roberto Saccon
> >
>


-- 
Roberto Saccon



More information about the erlang-questions mailing list