Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

newBie: dets problem

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #40285
    Peter
    Guest

    We’re having a problem with writing to the table. Maybe the insert doesn’t work? Is this the right way to do it:

    Error message:
    7> db:write(wnDb, 1,2,3,4,5,6,7,8).

    =ERROR REPORT==== 23-Nov-2004::11:12:04 ===
    Error in process with exit value: {badarg,[{dets,insert,[wnDb,{weatherN
    ow,1,2,3,4,5,6,7,8}]},{db,write,9},{erl_eval,do_apply,5},{shell,eval_loop,2}]}

    ** exited: {badarg,[{dets,insert,[wnDb,{weatherNow,1,2,3,4,5,6,7,8}]},
    {db,write,9},
    {erl_eval,do_apply,5},
    {shell,eval_loop,2}]} **

    Code:
    new() ->
    dets:open_file(wcDb, [{keypos, #weatherCast.wcId}]),
    dets:close(wcDb),
    dets:open_file(wnDb, [{keypos, #weatherNow.wnId}]),
    dets:close(wnDb),
    dets:open_file(wsDb, [{keypos, #weatherSite.wsId}]),
    dets:close(wsDb),
    dets:open_file(locDb, [{keypos, #location.locId}]),
    dets:close(locDb).

    write(TableName, Id, Wd, Ws, Te, We, Ti, Da, LocId) ->
    case dets:open_file(TableName) of
    {ok,_} ->
    dets:insert(TableName, #weatherNow{wnId=Id, windDir=Wd, windStr=Ws, temp=Te, weather=We, time=Ti, date=Da, locationId=LocId}),
    dets:close(TableName);
    {error,_} ->
    {error, instance}
    end.

Viewing 1 post (of 1 total)
  • The forum ‘Telecom Design’ is closed to new topics and replies.