Deleting rows in Mnesia

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Deleting rows in Mnesia

Thomas Schwarzkopf
Hi,

when I try to delete a row in a Mnesia table like this:

F = fun() -> mnesia:delete({sometable, somekey}) end.
mnesia:transaction(F).

returns

{atomic, ok}

even if somekey does not exist. Why is this?
I would expect an aborted transaction like in the case of a non-existing
tablename.

Thanks

Thomas

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Deleting rows in Mnesia

Håkan Mattsson
On Tue, Jul 20, 2010 at 6:57 PM, Thomas Schwarzkopf
<[hidden email]> wrote:

> Hi,
>
> when I try to delete a row in a Mnesia table like this:
>
> F = fun() -> mnesia:delete({sometable, somekey}) end.
> mnesia:transaction(F).
>
> returns
>
> {atomic, ok}
>
> even if somekey does not exist. Why is this?
> I would expect an aborted transaction like in the case of a non-existing
> tablename.

Access of a non-existing table is regarded as an error. It is very likely
that the application is not properly installed (forgot to create the table).

Whether a record with a given key exists or not at a given timepoint
is very application dependent. Mnesia does not bother.

/Håkan

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]