[erlang-questions] Issues with ets:match_delete

Code Wiget codewiget95@REDACTED
Thu Jul 12 22:35:54 CEST 2018


Hey everyone,

Lets say you have an ets table with entries as shown below:

{table_name, key, {A, [B]}.

I am trying to delete all table entries matching A. I can create a match like so:

ets:match(table_name, {'_', '_', {Node, '$1'}})

and it returns the values for B. But when I run match_delete or select_delete, I get a badarg error…:

> ets:match_delete(table_name, {'_', '_', {Node, '$1'}}).
> ** exception error: bad argument
>      in function  ets:select_delete/2
>         called as ets:select_delete(table_name,
>                                     [{{'_','_',{{{192,168,1,104},9042},'$1'}},[],[true]}])
>      in call from ets:match_delete/2 (ets.erl, line 726)
> (NODE)16> ets:select_delete(table_name, {'_', '_', {Node, '$1'}}).
> ** exception error: bad argument
>      in function  ets:select_delete/2
>         called as ets:select_delete(table_name,{'_','_',{{{192,168,1,104},9042},'$1'}})

So I tried to match and object and delete it...

> (NODE)17> ets:match_object(table_name, {'_', '_', {Node, '$1'}}).
> [{table_name,'$primary_cluster',
>                 Info…]
>
>
> (NODE)25> ets:delete_object(table_name, Info).
> ** exception error: bad argument
>      in function  ets:delete_object/2
>         called as ets:delete_object(table_name, …. )
>
I would like to avoid re-creating the table structure, as it is not from a project that I created and would take some time to fix all the code. How do I delete something from this table?

Thanks!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180712/31582e4c/attachment.htm>


More information about the erlang-questions mailing list