How to implement dynamic queries for MNesia?
        Posted  
        
            by Kerem
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Kerem
        
        
        
        Published on 2010-06-11T08:59:53Z
        Indexed on 
            2010/06/11
            9:02 UTC
        
        
        Read the original article
        Hit count: 366
        
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.
© Stack Overflow or respective owner