mnesia:transform_table

petra <>
Wed Dec 20 13:05:46 CET 2000


Hi!

I have a problem when I try to do a 
mnesia:transform_table(Tab, Fun, NewAttributeList) -> {aborted, R} | {atomic,
ok}

In the fun I'm trying to doing a ets:lookup but it won't work, I get the message
"Bad transform function" and lateron it says: "{badarg,{ets,lookup......."

Can't you do a ets:lookup when your transforming mnesia? Does anyone know?

Best regards,
 Petra Jansson

-record(ets_record, {ets_key, ets_id}).
-record(oldrecord, {key = 5, id = 6, newdata = 7}).

init() ->
    Ets = ets:new(new_ets, []),
    ets:insert(Ets, #ets_record{ets_key = 1, ets_id = 99}),
    main().
    

main() ->
    Fun = fun({oldrecord,
	       Key,
	       Id}) ->
		  #oldrecord{key = Key,
			     id = Id,
			     newdata = get_new_data()}
	  end,
    
    Retur = mnesia:transform_table(oldrecord,
				   Fun, record_info(fields, oldrecord)),
    io:format("Retur = ~p~n",[Retur]).

get_new_data() ->
    Data = ets:lookup(ets_record, 1),
    io:format("Data = ~p~n", [Data]),
    Data.

-- 
Get your  email for FREE at http://Nameplanet.com/?su



More information about the erlang-questions mailing list