How to delete a ets entry based on non key partPreserving relational integrity with MnesiaErlang BIF's to delete tuples in listUnable to use Erlang/ets in receive blockCan match specifications be used only for tracing and selecting from ets tables? Can they be used in a case expression?Mnesia: how to use indexed operations correctly when selecting rows based on criteria involving multiple, indexed columnsfunction which contains read and write from two table in erlangRabbitmq Key based AuthenticationMnesia deletion errorErlang ETS MatchCannot delete a mnesia table that I know exists

Adding empty element to declared container without declaring type of element

Is a naturally all "male" species possible?

The most efficient algorithm to find all possible integer pairs which sum to a given integer

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

How can I raise concerns with a new DM about XP splitting?

Why is delta-v is the most useful quantity for planning space travel?

How to deal with or prevent idle in the test team?

Can the electrostatic force be infinite in magnitude?

Can I use my Chinese passport to enter China after I acquired another citizenship?

Is there enough fresh water in the world to eradicate the drinking water crisis?

Have I saved too much for retirement so far?

Simple image editor tool to draw a simple box/rectangle in an existing image

Indicating multiple different modes of speech (fantasy language or telepathy)

Lifted its hind leg on or lifted its hind leg towards?

A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?

Is it okay / does it make sense for another player to join a running game of Munchkin?

Can a Bard use an arcane focus?

What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?

Can a Gentile theist be saved?

Should a half Jewish man be discouraged from marrying a Jewess?

Should my PhD thesis be submitted under my legal name?

Java - What do constructor type arguments mean when placed *before* the type?

Bob has never been a M before

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?



How to delete a ets entry based on non key part


Preserving relational integrity with MnesiaErlang BIF's to delete tuples in listUnable to use Erlang/ets in receive blockCan match specifications be used only for tracing and selecting from ets tables? Can they be used in a case expression?Mnesia: how to use indexed operations correctly when selecting rows based on criteria involving multiple, indexed columnsfunction which contains read and write from two table in erlangRabbitmq Key based AuthenticationMnesia deletion errorErlang ETS MatchCannot delete a mnesia table that I know exists













0















I have a etc table ‘table’ as key,[val1,val2]
I selected this data from the table using



ets:select(table,[‘$1','$2',[],['$$']]). 
[[key,["val1",<<"12">>]],
[key,["val2",<<"6">>]],
[key,["val3",<<"16">>]]]


I want to delete a entry matching the part [val1,val2] using this



ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],['$$']]).
0


But still when I run select again I get



ets:select(table,[‘$1','$2',[],['$$']]). 
[[key,["val1",<<"12">>]],
[key,["val2",<<"6">>]],
[key,["val3",<<"16">>]]]


How can I delete this entry based on the non key part?










share|improve this question




























    0















    I have a etc table ‘table’ as key,[val1,val2]
    I selected this data from the table using



    ets:select(table,[‘$1','$2',[],['$$']]). 
    [[key,["val1",<<"12">>]],
    [key,["val2",<<"6">>]],
    [key,["val3",<<"16">>]]]


    I want to delete a entry matching the part [val1,val2] using this



    ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],['$$']]).
    0


    But still when I run select again I get



    ets:select(table,[‘$1','$2',[],['$$']]). 
    [[key,["val1",<<"12">>]],
    [key,["val2",<<"6">>]],
    [key,["val3",<<"16">>]]]


    How can I delete this entry based on the non key part?










    share|improve this question


























      0












      0








      0








      I have a etc table ‘table’ as key,[val1,val2]
      I selected this data from the table using



      ets:select(table,[‘$1','$2',[],['$$']]). 
      [[key,["val1",<<"12">>]],
      [key,["val2",<<"6">>]],
      [key,["val3",<<"16">>]]]


      I want to delete a entry matching the part [val1,val2] using this



      ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],['$$']]).
      0


      But still when I run select again I get



      ets:select(table,[‘$1','$2',[],['$$']]). 
      [[key,["val1",<<"12">>]],
      [key,["val2",<<"6">>]],
      [key,["val3",<<"16">>]]]


      How can I delete this entry based on the non key part?










      share|improve this question
















      I have a etc table ‘table’ as key,[val1,val2]
      I selected this data from the table using



      ets:select(table,[‘$1','$2',[],['$$']]). 
      [[key,["val1",<<"12">>]],
      [key,["val2",<<"6">>]],
      [key,["val3",<<"16">>]]]


      I want to delete a entry matching the part [val1,val2] using this



      ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],['$$']]).
      0


      But still when I run select again I get



      ets:select(table,[‘$1','$2',[],['$$']]). 
      [[key,["val1",<<"12">>]],
      [key,["val2",<<"6">>]],
      [key,["val3",<<"16">>]]]


      How can I delete this entry based on the non key part?







      erlang






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 8:28







      abhishek ranjan

















      asked Mar 8 at 8:22









      abhishek ranjanabhishek ranjan

      98111




      98111






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The ets:select_delete documentation says:




          The match specification has to return the atom true if the object is to be deleted. No other return value gets the object deleted. So one cannot use the same match specification for looking up elements as for deleting them.




          So try this:



          ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]).


          ets:select_delete returns the number of records it deleted, so hopefully it should return 1 this time.






          share|improve this answer

























          • I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

            – abhishek ranjan
            Mar 8 at 9:44











          • Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

            – legoscia
            Mar 8 at 9:46












          • I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

            – abhishek ranjan
            Mar 8 at 9:58











          • I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

            – abhishek ranjan
            Mar 8 at 10:00











          • If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

            – legoscia
            Mar 8 at 10:06










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059238%2fhow-to-delete-a-ets-entry-based-on-non-key-part%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The ets:select_delete documentation says:




          The match specification has to return the atom true if the object is to be deleted. No other return value gets the object deleted. So one cannot use the same match specification for looking up elements as for deleting them.




          So try this:



          ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]).


          ets:select_delete returns the number of records it deleted, so hopefully it should return 1 this time.






          share|improve this answer

























          • I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

            – abhishek ranjan
            Mar 8 at 9:44











          • Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

            – legoscia
            Mar 8 at 9:46












          • I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

            – abhishek ranjan
            Mar 8 at 9:58











          • I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

            – abhishek ranjan
            Mar 8 at 10:00











          • If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

            – legoscia
            Mar 8 at 10:06















          0














          The ets:select_delete documentation says:




          The match specification has to return the atom true if the object is to be deleted. No other return value gets the object deleted. So one cannot use the same match specification for looking up elements as for deleting them.




          So try this:



          ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]).


          ets:select_delete returns the number of records it deleted, so hopefully it should return 1 this time.






          share|improve this answer

























          • I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

            – abhishek ranjan
            Mar 8 at 9:44











          • Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

            – legoscia
            Mar 8 at 9:46












          • I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

            – abhishek ranjan
            Mar 8 at 9:58











          • I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

            – abhishek ranjan
            Mar 8 at 10:00











          • If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

            – legoscia
            Mar 8 at 10:06













          0












          0








          0







          The ets:select_delete documentation says:




          The match specification has to return the atom true if the object is to be deleted. No other return value gets the object deleted. So one cannot use the same match specification for looking up elements as for deleting them.




          So try this:



          ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]).


          ets:select_delete returns the number of records it deleted, so hopefully it should return 1 this time.






          share|improve this answer















          The ets:select_delete documentation says:




          The match specification has to return the atom true if the object is to be deleted. No other return value gets the object deleted. So one cannot use the same match specification for looking up elements as for deleting them.




          So try this:



          ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]).


          ets:select_delete returns the number of records it deleted, so hopefully it should return 1 this time.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 9:45

























          answered Mar 8 at 9:36









          legoscialegoscia

          29.6k1185116




          29.6k1185116












          • I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

            – abhishek ranjan
            Mar 8 at 9:44











          • Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

            – legoscia
            Mar 8 at 9:46












          • I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

            – abhishek ranjan
            Mar 8 at 9:58











          • I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

            – abhishek ranjan
            Mar 8 at 10:00











          • If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

            – legoscia
            Mar 8 at 10:06

















          • I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

            – abhishek ranjan
            Mar 8 at 9:44











          • Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

            – legoscia
            Mar 8 at 9:46












          • I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

            – abhishek ranjan
            Mar 8 at 9:58











          • I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

            – abhishek ranjan
            Mar 8 at 10:00











          • If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

            – legoscia
            Mar 8 at 10:06
















          I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

          – abhishek ranjan
          Mar 8 at 9:44





          I used ets:select_delete(table,[‘$1','$2',['==','$2',["val1",<<"12">>]],true]). which gives a ` * 1: illegal character ` error.

          – abhishek ranjan
          Mar 8 at 9:44













          Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

          – legoscia
          Mar 8 at 9:46






          Oops, a smart quotation mark crept in. I edited the answer, please try again. (That is, the single quote right before $1 was not a "real" single quote.)

          – legoscia
          Mar 8 at 9:46














          I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

          – abhishek ranjan
          Mar 8 at 9:58





          I tried the updated command but I got this ` ets:select_delete(table,['$1','$2',['==','$2',["val1",<<"12">>]],true]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(table, ['$1','$2',['==','$2',["val1",<<"12">>]],true])` Plus the ets:select/2 command also give the same error now.

          – abhishek ranjan
          Mar 8 at 9:58













          I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

          – abhishek ranjan
          Mar 8 at 10:00





          I think by running the command with atom 'true' my table got deleted instead(I don't know how though).

          – abhishek ranjan
          Mar 8 at 10:00













          If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

          – legoscia
          Mar 8 at 10:06





          If you're creating the table in the shell, and then run something that crashes, the table will be deleted as it was owned by the shell process that crashed.

          – legoscia
          Mar 8 at 10:06



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059238%2fhow-to-delete-a-ets-entry-based-on-non-key-part%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme