---------- Original mail ---------- From: Alan DeKok <aland@deployingradius.com> To: FreeRadius users mailing list <freeradius-users@lists.freeradius.org> Date: 3. 10. 2017 16:55:57 Subject: Re: unlang, variable and SQL (freeradius 3.0.15) "On Oct 3, 2017, at 10:19 AM, <petr.linke@seznam.cz> <petr.linke@seznam.cz> wrote
I try to store result from SQL into local variable to eliminate running same queries at time.
I prepare following scenario:
1/ define new attribute (will be used for store the result from SQL) in the dictionary, attribute type is string (e.g. ATTRIBUTE SQLRESULT 3000 string) 2/ in inner tunnel post-auth section: update control { &SQLRESULT = "%{sql::SELECT count(*) from some_table where .. .}" }
Which places it into the control list.
if ( %{integer:SQLRESULT} == some_value ) {
Which looks for it in the request list. Use control:SQLRESULT instead. " Great, now all is OK, many thanks " Also, if the attribute is an integer, just define it as an integer in the dictionaries. Don't define it as a string and then convert it to an integer. " Yes, I know. This attribute was from my previous tests, and I was lazy to define new attribute :(. Only one simple question. If SQL query return more rows, is possible to store result from SQL in some special type of variable and use foreach statement to mine values from rows? Petr Linke