I am trying to implement a function that generates dynamic queries for MNesia.
For example, when a function is called with these arguments,
dyn_query(list, person, [name, age], ["jack", 21])
I want to ask MNesia for a list whose name is “jack” and age is 21 people. > table.
I tried to implement this with qlc: q (ListComprehension) and qlc: string_to_handle ("ListComprehension"). At first it failed due to compilation errors, the compiler did not allow me to use functions instead of ListComprehentions and variables instead of record names, such as "Item # Table.Field". The second failed because erl_eval was unable to process the entries and selected exceptions such as {undefined_record, person}.
Which method to use? How can I solve these problems? Or should I use a different method?
Thank.
source
share