how to lookup last record in dataset in Mnesia?

Christian S <>
Wed Jun 7 16:08:11 CEST 2006


Is there any way you could update a last-inserted-table on your own
each time you make a change? E.g. all modifications go through the
same code that makes sure the last-inserted-table is updated.

On 6/7/06, Gaspar Chilingarov <> wrote:
> Hello all!
>
>
> I have a table in Mnesia, which I with to filter by some field(s) and
> fetch one record with maximal ID (ie. last inserted).
>
> The only method I can imagine -
>
> make qlc query, sort it by ID in reverse order, create qlc cursor and
> fetch exactly  1 record from resulting dataset.
>
> (SQL equivalent: SELECT MAX(ID) FROM table WHERE foo_field = 'bar' and
> user_name = 'Alice')
>
> Are there any fast ways to achieve this in mnesia?
>
> Thanks in advance, Gaspar
>
> --
> Gaspar Chilingarov
>
> System Administrator,
> Network security consulting
>
> t +37493 419763 (mob)
> i 63174784
> e 
>



More information about the erlang-questions mailing list