<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div>Your ets:match_delete looks fine.</div>
<div>Are you sure the table is still alive? Try ets:info(table_name).</div>
<div><br>
</div>
<div>When you get an exception in the Erlang shell, the shell process will terminate and be restarted</div>
<div>losing all process specific resources such as ets tables.</div>
<div><br>
</div>
<div><br>
</div>
<div>/Sverker, Erlang/OTP</div>
<div><br>
</div>
<div><br>
</div>
<div>On tor, 2018-07-12 at 16:35 -0400, Code Wiget wrote:</div>
<blockquote type="cite">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
Hey everyone,
<div><br>
</div>
<div>Lets say you have an ets table with entries as shown below:</div>
<div><br>
</div>
<div>{table_name, key, {A, [B]}. </div>
<div><br>
</div>
<div>I am trying to delete all table entries matching A. I can create a match like so:</div>
<div><br>
</div>
<div>ets:match(table_name, {'_', '_', {Node, '$1'}}) </div>
<div><br>
</div>
<div>and it returns the values for B. But when I run match_delete or select_delete, I get a badarg error…:<br>
</div>
<div><br>
</div>
<blockquote style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">
<div>
<div>ets:match_delete(table_name, {'_', '_', {Node, '$1'}}).</div>
</div>
<div>
<div>** exception error: bad argument</div>
</div>
<div>
<div>     in function  ets:select_delete/2</div>
</div>
<div>
<div>        called as ets:select_delete(table_name,</div>
</div>
<div>
<div>                                    [{{'_','_',{{{192,168,1,104},9042},'$1'}},[],[true]}])</div>
</div>
<div>
<div>     in call from ets:match_delete/2 (ets.erl, line 726)</div>
</div>
<div>
<div>(NODE)16> ets:select_delete(table_name, {'_', '_', {Node, '$1'}}).</div>
</div>
<div>
<div>** exception error: bad argument</div>
</div>
<div>
<div>     in function  ets:select_delete/2</div>
</div>
<div>
<div>        called as ets:select_delete(table_name,{'_','_',{{{192,168,1,104},9042},'$1'}})</div>
</div>
</blockquote>
<div>
<div><br>
</div>
<div>So I tried to match and object and delete it...</div>
<div><br>
</div>
</div>
<blockquote style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">
<div>
<div>(NODE)17> ets:match_object(table_name, {'_', '_', {Node, '$1'}}). </div>
</div>
<div>
<div>[{table_name,'$primary_cluster',</div>
</div>
<div>
<div>                Info…]</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>(NODE)25> ets:delete_object(table_name, Info).                                                        </div>
</div>
<div>
<div>** exception error: bad argument</div>
</div>
<div>
<div>     in function  ets:delete_object/2</div>
</div>
<div>
<div>        called as ets:delete_object(table_name, …. )</div>
</div>
<div><br>
</div>
</blockquote>
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?
<div><br>
</div>
<div>Thanks!<br>
<div><br>
</div>
</div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<br>
<div></div>
</div>
<pre>_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
</body>
</html>