Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  [Q] how to create table definition and table at runtime

vsp
Posted: Sun Jun 06, 2010 4:42 am Reply with quote
User Joined: 03 Mar 2010 Posts: 14
Hello,
I need to be able to define a mnesia table (and then potentially populate it) at run time.

all the examples I saw before use -record to define a structure and then create the table.

However, in my situation it is only at runtime I can 'devise' that information.

And then I need all of my modules to be able to access this newly created table.

thanks in advance
View user's profile Send private message
bpuzon
Posted: Mon Jun 07, 2010 9:22 am Reply with quote
User Joined: 05 Aug 2009 Posts: 23 Location: Cracow, Poland
I think you can simply create your table on runtime using
Code:

mnesia:create_table(something, [{attributes, [some_atoms]}])

[some_atoms] does not _have_ to be created from record_info().

_________________
Saludos,
Bartłomiej Puzoń
Erlang Solutions
View user's profile Send private message Visit poster's website
vsp
Posted: Mon Jun 07, 2010 5:49 pm Reply with quote
User Joined: 03 Mar 2010 Posts: 14
thank you,
but this would not allow me to 'use' the table from modules, correct?

In other words, there is no way for me to introspect a table definition and then create a 'record structure' for it ?


thank you
View user's profile Send private message
bpuzon
Posted: Mon Jun 07, 2010 6:42 pm Reply with quote
User Joined: 05 Aug 2009 Posts: 23 Location: Cracow, Poland
Well, records are syntactic sugar and disappear after the preprocessing. So everything you can do with records, you can do without as well.

If for some reason mnesia:table_info(table, attributes) doesn't work for you (why?) you might need to send the (generated) attributes to your other processes that wish to use the table.

_________________
Saludos,
Bartłomiej Puzoń
Erlang Solutions
View user's profile Send private message Visit poster's website
wuji
Posted: Sat Aug 11, 2012 2:15 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
than half a century, and a football team's worth of of Cheap Ralph Lauren Shirts of children and grandchildren."He died as he lived. He
hard until the end, stayed positive, thought only of others others replica Christian Louboutin others and constantly reminded everyone of how blessed his life
been. His ambitions were far reaching, but he never never discount designer *beep* never believed he had to leave this Happy Valley to
them. He was a man devoted to his family, family, [h4]designer replica *beep*[/h4] family, his university, his players and his community," Paterno's family
in a statement.While at Penn State's helm, Paterno, who was was [h2]replica designer bags for sale[/h2] was born in Brooklyn, N.Y., led the Nittany Lions to
undefeated seasons and two NCAA championships, had only five losing losing cheap Ralph Lauren Polo losing seasons, was inducted into the College Football Hall of
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum