September 2013
Intermediate to advanced
548 pages
12h 25m
English
When we added or removed data from the database or performed a query, we wrote the code something like this:
| | do_something(...) -> |
| | F = fun() -> |
| | % ... |
| | mnesia:write(Row) |
| | % ... or ... |
| | mnesia:delete(Oid) |
| | % ... or ... |
| | qlc:e(Q) |
| | end, |
| | mnesia:transaction(F) |
F is a fun with zero arguments. Inside F we called
some combination of mnesia:write/1,
mnesia:delete/1, or qlc:e(Q) (where Q
is a query compiled with qlc:q/1). Having built the
fun, we call mnesia:transaction(F), which evaluates the
expression sequence in the fun.
Transactions guard against faulty program code but more importantly against concurrent access of the database. Suppose we have two processes that try to simultaneously access the same data. ...
Read now
Unlock full access