|
|
| Author |
Message |
< Erlang ~ How do you write an mnesia update query? |
| LRP |
Posted: Mon Oct 13, 2008 3:04 am |
|
|
|
Joined: 08 Oct 2008
Posts: 8
Location: Boston, MA.
|
Hello,
At risk of sounding desperate (fast getting there), I'm rephrasing the question I posted on October 8.
Suppose I have the following record structure:
-record(news,
{newsID,
head,
copy,
dateline}).
...where head and copy are binaries. How do I write a mnesia query to update the head and/or copy fields?
Table is initialized as follows:
init_newswire() ->
% Initialize database
mnesia:create_schema([node()]),
mnesia:start(),
try
mnesia:table_info(news, type)
catch
exit: _ ->
mnesia:create_table(news, [
{attributes, record_info(fields, news)},
{type, set},
{disc_copies, [node()] }
])
end.
Seems to me that every good erlang programmer would know how to do this, but there were no responses to my post and I come up blank in my Google searches.
Many thanks,
LRP |
|
|
| Back to top |
|
| klaar |
Posted: Wed Oct 15, 2008 10:18 pm |
|
|
|
User
Joined: 06 Oct 2008
Posts: 11
Location: Göteborg/Sweden
|
It depends upon which type of table that is used. If you are using (set|ordered_set) then just write it again, just like you did the first time. The old version will be overwritten, so make sure that you have read out _all_ of the data before you do this
http://www.erlang.org/doc/apps/mnesia/index.html |
|
|
| Back to top |
|
| LRP |
Posted: Wed Oct 15, 2008 10:28 pm |
|
|
|
Joined: 08 Oct 2008
Posts: 8
Location: Boston, MA.
|
Many thanks.
I did scour the menesia reference manual. But must have missed... or misunderstood how to update records.
Thanks again,
LRP |
|
|
| Back to top |
|
| Mazen |
Posted: Thu Oct 16, 2008 7:30 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
My excuse:
The word "query" threw me off...
 |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|