mnesia primary key creation
Roberto Saccon
rsaccon@REDACTED
Tue Jul 4 23:37:06 CEST 2006
Thanks, after seeing the example it looks soooo simple and obvious !
On 7/4/06, Ulf Wiger <ulf@REDACTED> wrote:
> Den 2006-07-04 21:31:26 skrev Roberto Saccon <rsaccon@REDACTED>:
>
> > I liked the cheap solution:
> >
> > oid() -> {node(), erlang:now()}.
> >
> > but how can I turn erlang:now() into a String ?? (which probablly
> > won't look very URL-friendly)
> >
> > I thouhgt of turing it into a list, then into a binary, then base64
> > encoding it, but
> > list_to_binary(tuple_to_list(erlang:now()))
> > does not work.
>
> Well, for example:
>
> 1> {Node,{MS,S,US}} = {node(), erlang:now()}.
> {nonode@REDACTED,{1152,47770,297000}}
> 2>
> list_to_binary([atom_to_list(Node),"-",integer_to_list(MS),"-",integer_to_list(S),"-",integer_to_list(US)]).
> <<110,111,110,111,100,101,64,110,111,104,111,115,116,45,49,49,53,50,45,52,55,55,55,48,45,50,57,55,48,...>>
> 3> binary_to_list(v(2)).
> "nonode@REDACTED"
>
> BR,
> Ulf W
>
> --
> Ulf Wiger
>
--
Roberto Saccon
More information about the erlang-questions
mailing list