[erlang-questions] How to find an object in an ETS table ?

Hynek Vychodil <>
Fri Nov 26 17:07:06 CET 2010


On Fri, Nov 26, 2010 at 4:31 PM, info <> wrote:
> Hello,
>
> Probably an error of beginner ...
> E=ets:new('my_table',[]),
> ets:insert(E,{123,1}),
> ets:insert(E,{456,2}),
> The following command find the key 123 and return the object 1
> ets:lookup(E,123),
> The following command returns empty !
> R1=ets:match(E,{'_',2,'$1'}),
> How to find the object 2 ?
>
> J-Ph. Constantin
> ITS3 Genève
> www.its3.ch
>

You may be want to do

ets:match(E,{'$1',2}).

or

ets:match_object(E,{'$1',2}).

or may be

ets:select(E, [{{'_',2}, [], ['$_']}]).

-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill
your boss.  Be a data hero!
Try GoodData now for free: www.gooddata.com


More information about the erlang-questions mailing list