How Mnemosyne cursors are used ?

Massimo Cesaro massimo.cesaro@REDACTED
Wed Nov 12 08:54:46 CET 2003

I'd like to have a function that when called returns, up to N records
from a Mnesia table. The records are extracted using a Mnemosyne query,
and I thought the I could do something like this:

get_page(StartDate, EndDate, Result, MaxLines)  ->
    Q = query [C || C <- table(cdr),
           >= StartDate,
           =< EndDate,
                    C.result = Result
    F= fun() -> 
               Cursor = mnemosyne:cursor(Q),
               L = mnemosyne:next_answers(Cursor, MaxLines, MaxLines),
               [Cursor, L]

    % Get the first MaxLines records
    {R, [C, L]}= mnesia:transaction(F),

    % format and display records

    % Get another block of records
    K = mnesia:transaction(fun() -> mnemosyne:next_answers(C) end),


I get the first block correctly, but on the second
mnemosyne:next_answers() call, I have a "wrong transaction" error.

Clearly this is not the way the cursors should be used, but then how can
I query the database in discrete blocks (let say that I want to print
the records on different pages of a report), maintaining the cursor
status between separate calls ?


More information about the erlang-questions mailing list