[erlang-questions] Why is this delete_object giving me an error?

Jeroen Koops koops.j@REDACTED
Mon Mar 16 14:21:51 CET 2009


dirty_delete_object (and also delete_object) can only be used with a
complete record - i.e. all fields must be filled in. It does not accept
wildcard patterns.

If you want to delete all user with a certain first name, you need an index
on the first_name attribute, query for all users with that first name using
mnesia:index_read or dirty_index_read, and finally manually delete all
returned records with delete_object or delete.



On Mon, Mar 16, 2009 at 2:05 PM, ryeguy <ryeguy1@REDACTED> wrote:

> I don't see what's wrong here, but I may just misunderstand the
> syntax. I'm trying to delete a "user" record from my "user" mnesia
> table who have the first name of "ryan" (there are multiples of them).
> Here is what I do:
> Delete=#user{first_name = "ryan", _ = '_'},
> mnesia:dirty_delete_object(Delete)
> Here is my record definition:
> -record(user, {id,
>                           username,
>                           password,
>                           email,
>                           first_name,
>                           last_name,
>                           last_login, % Date/time user last logged in
>                           reg_date}). % Date/time user registered the
> account
> And here is the exception I'm getting:
> ** exception exit: {aborted,
>                       {bad_type,user,
>                           {user,'_','_','_','_',"ryan",'_','_','_'}}}
>     in function  mnesia:abort/1
>     in call from users:register/1
> It seems like a perfect match. What could cause this problem?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090316/826339fa/attachment.htm>

More information about the erlang-questions mailing list