Category: Programming

Provided that you want to increase or update the field YOUR_UPDATE_FIELD in table YOUR_TABLE with a key YOUR_TABLE_KEY_VALUE,
just use the following codes.

Query =
fun() ->
[OldRecord] = mnesia:read(YOUR_TABLE, YOUR_TABLE_KEY_VALUE, write),
P = OldRecord#YOUR_TABLE.YOUR_UPDATE_FIELD + 1,
NewRecord = OldRecord#operator{ YOUR_UPDATE_FIELD = P },
mnesia:write(NewRecord)
end,
{atomic, Result} = mnesia:transaction(Query).

Q1 = qlc:q([X || X <- mnesia:table(YOUR_TABLE)]),
{atomic,T1} = mnesia:transaction(fun()->qlc:eval(Q1)  end),
T1.

Replace YOUR_TABLE with the table name of your mnesia table,
insert the code above in your erlang module,
you will get the data in T1.

最近Reveiw Django 的代码, 仍然用自己常用的Editplus 作为编辑器。但是默认Editplus 并没有对python代码高亮。于是找到以下插件:

python

将此解压到editplus目录,并且配置py结尾的文件用此插件进行高亮处理。