[erlang-questions] Simple, how to do "paging" with mnesia records
Kenneth Lundin
kenneth.lundin@REDACTED
Thu Oct 18 17:45:56 CEST 2007
Look at the documentation for QLC
http://www.erlang.org/doc/man/qlc.html
With QLC you can do access mnesia with a cursor in which you specify
how many answers you want.
By the way mnemosyne that you use in your example is a deprecated application
that will be removed from the distribution in the next release i.e
before end of 2007.
/Kenneth (Erlang/OTP team at Ericsson)
On 10/17/07, bbrown <bbrown@REDACTED> wrote:
> 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);
> query.setMaxResults(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},
> #entity_links{link_id=2}
> ]]
> end,
> F = fun() -> mnemosyne:eval(Q) end,
> case mnesia:transaction(F) of
> {atomic, Result} -> {ok, Result};
> {aborted, Reason} -> {error, Reason}
> end.
>
>
>
> --
> Berlin Brown
> [berlin dot brown at gmail dot com]
> http://botspiritcompany.com/botlist/?
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list