Hotdesking database problem with mysql

I am trying to implement the hot desk function from the “Asterisk” book but I have come up against a problem with the func_odbc part.

When I try to connect from SIP phone desk1 to a users extension the location field does not get updated even though the status field does get updated and logout removes the desk entry in the table.

If I put desk1 in the location filed by hand the phone answers the logged in extension number correctly.

I can’t see where my problem is.

==================Configs follow==============

from extensions.conf, the valid_login code

exten => valid_login,1,NoOp()
exten => valid_login,n,Set(LOCATION=${CUT(CHANNEL,/,2)})
exten => valid_login,n,Set(LOCATION=${CUT(LOCATION,-,1)})
exten => valid_login,n,Set(ARRAY(USERS_LOGGED_IN)=${HOTDESK_CHECK_PHONE_LOGINS(${LOCATION})})
exten => valid_login,n,GotoIf($[${USERS_LOGGED_IN} > 0]?logout_login,1)
exten => valid_login,n(set_login_status),NoOp()
exten => valid_login,n,Set(HOTDESK_STATUS(${E})=1,${LOCATION})
exten => valid_login,n,GotoIf($[${ODBCROWS} < 1]?error,1)
exten => valid_login,n,Playback(agent-loginok)
exten => valid_login,n,Hangup()


from func_odbc.conf
[STATUS]
prefix=HOTDESK
dsn=asterisk
writesql=UPDATE ast_hotdesk SET status = ‘${VAL1}’, location = ‘${VAL2}’ WHERE extension = ‘${ARG1}’


from the log

– Executing [valid_login@hotdesk:1] NoOp(“SIP/desk1-08e95980”, “”) in new stack
– Executing [valid_login@hotdesk:2] Set(“SIP/desk1-08e95980”, “LOCATION=desk1-08e95980”) in new stack
– Executing [valid_login@hotdesk:3] Set(“SIP/desk1-08e95980”, “LOCATION=desk1”) in new stack
– Executing [valid_login@hotdesk:4] Set(“SIP/desk1-08e95980”, “ARRAY(USERS_LOGGED_IN)=0”) in new stack
– Executing [valid_login@hotdesk:5] GotoIf(“SIP/desk1-08e95980”, “0?logout_login,1”) in new stack
– Executing [valid_login@hotdesk:6] NoOp(“SIP/desk1-08e95980”, “”) in new stack
– Executing [valid_login@hotdesk:7] Set(“SIP/desk1-08e95980”, “HOTDESK_STATUS(1239)=1,desk1”) in new stack
– Executing [valid_login@hotdesk:8] GotoIf(“SIP/desk1-08e95980”, “0?error,1”) in new stack
– Executing [valid_login@hotdesk:9] Playback(“SIP/desk1-08e95980”, “agent-loginok”) in new stack
– <SIP/desk1-08e95980> Playing ‘agent-loginok.slin’ (language ‘en’)
– Executing [valid_login@hotdesk:10] Hangup(“SIP/desk1-08e95980”, “”) in new stack
== Spawn extension (hotdesk, valid_login, 10) exited non-zero on ‘SIP/desk1-08e95980’


What the table looks like e.g

select * from ast_hotdesk;

16 | 1264 | First | Last | cid_name | 02075921264 | 264 | hotdesk_phones | 1 | |

instead of

16 | 1264 | First | Last | cid_name | 02075921264 | 264 | hotdesk_phones | 1 | desk1 |

what the table looks like

mysql> show columns from ast_hotdesk;
±-----------±-------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±-----------±-------------±-----±----±--------±---------------+
| id | mediumint(9) | NO | PRI | NULL | auto_increment |
| extension | char(30) | NO | | NULL | |
| first_name | char(30) | NO | | NULL | |
| last_name | char(20) | NO | | NULL | |
| cid_name | char(20) | NO | | NULL | |
| cid_number | char(20) | NO | | NULL | |
| pin | char(4) | NO | | NULL | |
| context | char(40) | NO | | NULL | |
| status | tinyint(1) | YES | | 0 | |
| location | char(10) | NO | | NULL | |
±-----------±-------------±-----±----±--------±---------------+

Fixed:

Between 1.6.0.5 and 1.6.1.1 the requirements for the SET function in the dialplan changed.

exten => valid_login,n,Set(HOTDESK_STATUS(${E})=1,${LOCATION})

to

exten => valid_login,n,Set(HOTDESK_STATUS(${E})=1,${LOCATION})

(i.e took out the “” escaping the “,” and everything now works.