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
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
add a comment |
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
add a comment |
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
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
erlang
edited Mar 8 at 8:28
abhishek ranjan
asked Mar 8 at 8:22
abhishek ranjanabhishek ranjan
98111
98111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
I usedets: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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
I usedets: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
|
show 1 more comment
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.
I usedets: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
|
show 1 more comment
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.
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.
edited Mar 8 at 9:45
answered Mar 8 at 9:36
legoscialegoscia
29.6k1185116
29.6k1185116
I usedets: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
|
show 1 more comment
I usedets: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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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