sql insert via unlang
Anton Borisov
antonio at mccinet.ru
Tue Jan 27 21:36:58 CET 2009
Good day!
So, I try to INSERT (unlang) data into my sql table;
I made in site-enable/default something like this:
if ( Service-Type == Framed-User ) {
if ( "%{sqlauth: INSERT into MYTAB VALUES ('1','2','3','4')}" ) {
ok
}
}
and it does not work....
Tue Jan 27 23:06:32 2009 : Info: expand: INSERT into MYTAB ...
Tue Jan 27 23:06:32 2009 : Debug: rlm_sql (sqlauth): Reserving sql
socket id: 0
Tue Jan 27 23:06:32 2009 : Error: rlm_sql_oracle: query failed in
sql_select_query: ORA-24333: zero iteration count
Tue Jan 27 23:06:32 2009 : Error: rlm_sql_oracle: OCI_SERVER_NORMAL
well, if I change my INSERT -> SELECT (for example)
if ( Service-Type == Framed-User ) {
if ( "%{sqlauth: SELECT COUNT from MYTAB}" ) {
ok
}
}
this works well..
Tue Jan 27 23:06:57 2009 : Debug: rlm_sql (sqlauth): Reserving sql
socket id: 0
Tue Jan 27 23:06:57 2009 : Info: sql_xlat finished
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Tue Jan 27 23:06:57 2009 : Debug: rlm_sql (sqlauth): Released sql socket
id: 0
In rlm_sql.c :
/*
* sql xlat function. Right now only SELECTs are supported. Only
* the first element of the SELECT result will be used.
*/
Oh, I am really very interested in INSERT sql. Please, tell me, Is this
right? Can I insert or update any data into my DB? Can I use another way
for INSERT sql data when I do not use sql accounting and
accounting_start_query/stop_query statement?
I need to insert or update sql data when my customers do authorize check.
Thank you.
Alan DeKok:
> Flamur Rogova wrote:
>> in my authorize section, I have this,
>> ...
>> check_password
>> if(notfound) {
>> # log notfound to sql, the line below gives error...
>> "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}',
>> test.description='user not found' }"
>
> You cannot put strings into the configuration like that.
>
>> man unlang says it is possible to obtain results from db, but I need to
>> execute only sql INSERT,
>> is my syntax wrong ?
>
> Yes. Nothing in the documentation says that this will work.
>
> You can do:
>
> if ("%{sql:INSERT ..."") {
> ok
> }
>
> Alan DeKok.
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
--
Yours faithfully,
Anton Borisov.
More information about the Freeradius-Users
mailing list