<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Hi, list:<br><br> I have a mnesia table about 15K records in my application. As the time goes, I find that some records(10K) in the table is useless. So I want to delete these useless items with a piece of code like this:<br><br>Here is the code:<br>%%%%%%%%%%%%%%%%%%%%%<br>1. delete() -><br>2. traversal_tab(tab).<br> <br> 3. traversal_tab(TabName) -><br>4. traversal_tab(TabName, mnesia:dirty_first(TabName)) .<br> <br>5. traversal_tab(TabName, '$end_of_table') -><br>6. io:format("finished~n");<br> 7. traversal_tab(TabName, Key) -><br>8. delete_entry(TabName, Key),<br>9. traversal_tab(TabName, mnesia:dirty_next(TabName, Key)).<br> <br>10. delete_entry(TabName, Key) -><br>11. if ... <br> %% delete the record if it fulfils the condition.<br>12. mnesia:dirty_delete(TabName, Key)<br> ...</div><div>13. end.<br>%%%%%%%%%%%%%%%%%%%%%%%%<br><br>The problem is if I delete the certain record in line 12, the function mnesia:dirty_next(TabName, Key) in line 9 will fail.<br>How to delete records when i traverse a mnesia table? Anyone Help? <br><br>Thank you !<br><br>Regards<br>Quan Zhuo<br></div> </div></body>
</html>