[erlang-questions] mnesia:subscribe doco and examples?

Hakan Mattsson hakan@REDACTED
Thu Feb 8 12:06:18 CET 2007


On Thu, 8 Feb 2007, jm wrote:

j> Date: Thu, 08 Feb 2007 11:37:19 +1100
j> From: jm <jeffm@REDACTED>
j> To: erlang-questions <erlang-questions@REDACTED>
j> Subject: [erlang-questions] mnesia:subscribe doco and examples?
j> 
j> The manual pages for mnesia say that mnesia:subscribe is docomented in 
j> the mnesia user manual. I assume this means the document entitled 
j> "Mnesia Database Managment System (MNESIA)" in wish I am unable to find
j> anything. Actually not quite nothing section 1.5.7 "Mnesia Event
j> Handling" contains a description of the available events. What I suppose 
j> I'm after is a couple of examples of the usage to get a more concrete 
j> idea of how it's used. Anyone care to point me in the right direction?

There are no examples in the "Mnesia Event Handling"
section as you already have found out, but it does
provide an exhaustive list of all events.

Here is a small example?

# erl
Erlang (BEAM) emulator version 5.5.3 [source] [async-threads:0] [kernel-poll:false]

Eshell V5.5.3  (abort with ^G)
1> mnesia:start().
ok
2> mnesia:create_table(t,[]).
{atomic,ok}
3> mnesia:subscribe({table, t}).
{ok,nonode@REDACTED}
4> mnesia:dirty_write(t, {t,12,4 2}).
ok
5> mnesia:dirty_write(t, {t, 12, 43}).
ok
6> mnesia:dirty_delete(t, 12).
ok
7> flush().
Shell got {mnesia_table_event,{write,{t,12,42},{dirty,<0.30.0>}}}
Shell got {mnesia_table_event,{write,{t,12,43},{dirty,<0.30.0>}}}
Shell got {mnesia_table_event,{delete,{t,12},{dirty,<0.30.0>}}}
ok
8> 

/Håkan


More information about the erlang-questions mailing list