<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
I've got a record nested within a record like this:<div><br></div><div>{account_wrapper, "Username", {account_data, ...}}</div><div><br></div><div>And what I want to do is use QLC to search that inner record and see if someone already has chosen a nickname for an account during registration. However, since I've never used QLC before I wanted to start out slow and just get a feel, creating more complex QLC's as I went along until I got where I wanted to go. First I tried this:</div><div><br></div><div>mnesia:activity(transaction, fun() -> qlc:eval(qlc:q([{A, B, C} || Wrapper <- mnesia:table(accounts), {A, B, C} <- Wrapper])) end, []).</div><div><br></div><div>I just wanted to make sure I understood how to unpack data structures...however I keep getting a qlc error:</div><div><br></div><div><div>** exception exit: {aborted,{badarg,[{qlc,eval,</div><div>                                          [{error,qlc,</div><div>                                                  {1,qlc,{used_generator_variable,'Wrapper'}}},</div><div>                                           []]},</div><div>                                     {mnesia_tm,apply_fun,3},</div><div>                                     {mnesia_tm,execute_transaction,5},</div><div>                                     {mnesia,wrap_trans,6},</div><div>                                     {erl_eval,do_apply,5},</div><div>                                     {shell,exprs,7},</div><div>                                     {shell,eval_exprs,7},</div><div>                                     {shell,eval_loop,3}]}}</div><div>     in function  mnesia:wrap_trans/6</div><div><br></div><div><br></div><div>Now from everything I've read...I thought I'd be able to use the Wrapper variable later on in the query as a generator...thus allowing me to unpack things. Why would this be giving me an error? If I change it to:</div></div><div><br></div><div>mnesia:activity(transaction, fun() -> qlc:eval(qlc:q([{A, B, C} || {A, B, C} <- mnesia:table(accounts)])) end, []).</div><div><br></div><div>It works just fine and returns the record...and I can successfully match the pattern {A, B, C} with the account_wrapper record elsewhere. So what am I missing?</div><div><br></div><div>Chris Hicks.</div><div><br></div>                                     </body>
</html>