How to implement dynamic queries for MNesia?
- by Kerem
I'm trying to implement a function that generates dynamic queries for MNesia.
For example, when function is called with these arguments;
dyn_query(list, person, [name, age], ["jack", 21])
I want to query MNesia to list items whose name is "jack" and age is 21 in person table.
I've tried to implement this by using qlc:q(ListComprehension) and qlc:string_to_handle("ListComprehension"). First failed because of compile errors, compiler didn't let me to use functions instead of ListComprehentions and variables instead of record names like "Item#Table.Member". Second failed, because erl_eval couldn't handle records and throwed exceptions like {undefined_record, person}.
Which method should I use? How could i solve these problems? Or should I use a different method?
Thanks.