unlang, variable and SQL (freeradius 3.0.15)

petr.linke at seznam.cz petr.linke at seznam.cz
Tue Oct 3 17:51:51 CEST 2017


---------- Original mail ----------
From: Alan DeKok <aland at deployingradius.com>
To: FreeRadius users mailing list <freeradius-users at 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 at seznam.cz> <petr.linke at 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


More information about the Freeradius-Users mailing list