[erlang-questions] Issues with ets:match_delete
Sverker Eriksson
sverker.eriksson@REDACTED
Fri Jul 13 13:24:37 CEST 2018
Your ets:match_delete looks fine.
Are you sure the table is still alive? Try ets:info(table_name).
When you get an exception in the Erlang shell, the shell process will terminate and be restarted
losing all process specific resources such as ets tables.
/Sverker, Erlang/OTP
On tor, 2018-07-12 at 16:35 -0400, Code Wiget wrote:
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!
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED<mailto:erlang-questions@REDACTED>
http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180713/ee61870c/attachment.htm>
More information about the erlang-questions
mailing list