UnLang SQL query vs Perl SQL query

Arran Cudbard-Bell a.cudbardb at freeradius.org
Mon Mar 4 23:20:32 CET 2013

On 4 Mar 2013, at 16:36, Mehdi Ravanbakhsh <babakco at gmail.com> wrote:

> I need to transfer  one radacc Table record to  another table (backup radacc) , Transfer means insert in new table and Dell from  first one  and  this is happen every time   each user get  [ Acct-Status-Type == 'Stop ] .
>  i use perl script to do some calculate and return  3 replay attribute and change 3 check attribute in radcheck table  and Unlang just work to  execute perl script .


> so in this  case i need to use Perl  in general but i can use unlang and Perl to connect and update database by SQL query  i need to know that  which one is faster  and which way has more performance :
> Perl Directly connecting to PostgreSQL database

Perl as you can select all the values in one query, or the fastest would be to create a stored procedure and call it with unlang, but i'm not that familiar with PgSQL procedures so I can't tell you how to do that.

> OR
> Use Unlang to connect to database by freeradius PGSQL database back-end.
> and in final i am not understand  meaning of   " Likely unlang if you only want to retrieve one value."  it means that is limitation    SQL  query in UnLang  ?

Yes. Unlang/XLAT queries will only assign the value of the first column.

update request {
	Tmp-String-0 = "%{sql:SELECT `a`, `b` FROM `foo` WHERE `bar` = 1;}"

Tmp-String-0 will only hold the value of column a.

More information about the Freeradius-Users mailing list