[erlang-questions] Simple, how to do "paging" with mnesia records

bbrown <>
Wed Oct 17 20:01:59 CEST 2007

For example, in java I might do the following to set at some "start" index 
and then only return X number of records.  This may operate independent of 
the ids in question.

query.setFirstResult(page * pageSize);
List data = query.list();

What is a mnesia approach for doing this.

Eg, I was going to use something along the following And then maybe do a less 
than link_id > than.  But I havent made it yet.  And yes, I probably need to 
do a little bit more research.  But I thought I would ask before I waste of 
day of work.

page_links() ->
    Q = query [E || E <- mnesia:table(entity_links),
		    E <- [#entity_links{link_id=1},
    F = fun() -> mnemosyne:eval(Q) end,
    case mnesia:transaction(F) of
        {atomic, Result}  -> {ok, Result};
        {aborted, Reason} -> {error, Reason}

Berlin Brown
[berlin dot brown at gmail dot com]

More information about the erlang-questions mailing list