Unable to query database in RealTime mysql


#1

ODBC query function return NULL in the log. This is what I have in my func_odbc.conf file

[LANG]
dsn=asterisk
readsql=SELECT language FROM sipfriends WHERE name='${SQL_ESC(${ARG1})}'

In my dialplan I have this

[internal]

exten => 5679,1,NoOp()
exten => 5679,2,WaitExten(1)
exten => 5679,3,GotoIf($["${ODBC_LANG}" = "en"]?Voicemail_en,1:Voicemail_de,1)

exten => Voicemail_de,1,NoOp()
exten => Voicemail_de,2,Set(COUNT=${ODBC_EXIST(${CALLERID(num)})})
exten => Voicemail_de,3,GotoIf($["${COUNT}" > "0"]?Voicemail_de,4:5)
exten => Voicemail_de,4,VoicemailMain(${CALLERID(num)}@VoiceMail)
exten => Voicemail_de,5,Playback(mainmenu)
exten => Voicemail_de,6,Hangup()

exten => Voicemail_en,1,NoOp()
exten => Voicemail_en,2,Set(PIN=${ODBC_PINCHECK(${CALLERID(num)})})
exten => Voicemail_en,3,Playback(vm-password)
exten => Voicemail_en,4,Read(DIGIT,,4)
exten => Voicemail_en,5,Hangup()

No matter if I call from number which I’m sure that language is equal to ‘en’ the call always goes to

exten => Voicemail_de,1,NoOp()

In full log I see this

[Dec 6 16:33:05] DEBUG[34192][C-0000001c] pbx.c: Launching ‘WaitExten’
[Dec 6 16:33:06] DEBUG[34192][C-0000001c] pbx_variables.c: Result of ‘ODBC_LANG’ is NULL
[Dec 6 16:33:06] DEBUG[34192][C-0000001c] pbx_variables.c: Expression result is ‘0’
[Dec 6 16:33:06] DEBUG[34192][C-0000001c] pbx.c: Launching ‘GotoIf’
[Dec 6 16:33:06] DEBUG[34192][C-0000001c] pbx.c: Launching ‘NoOp’

In asterisk CLI this:

== Using SIP RTP CoS mark 5
– Executing [5679@internal:1] NoOp(“SIP/1001-00000014”, “”) in new stack
– Executing [5679@internal:2] WaitExten(“SIP/1001-00000014”, “1”) in new stack
– Timeout on SIP/1001-00000014, continuing…
– Executing [5679@internal:3] GotoIf(“SIP/1001-00000014”, “0?Voicemail_en,1:Voicemail_de,1”) in new stack
– Goto (internal,Voicemail_de,1)
– Executing [Voicemail_de@internal:1] NoOp(“SIP/1001-00000014”, “”) in new stack

What can be the problem?


#2

I don’t see that you are passing in ARG1 to your ODBC_LANG function.


#3

Hi @johnkiniston. Thanks for the reply. You’re correct! I’ve changed the extension to:

exten => 5679,3,GotoIf($["${ODBC_LANG(${CALLERID(num)})}" = "en"]?Voicemail_en,1:Voicemail_de,1)

Now I see it on the CLI which seems okay to me now.

== Using SIP RTP CoS mark 5
– Executing [5679@internal:1] NoOp(“SIP/1001-00000016”, “”) in new stack
– Executing [5679@internal:2] WaitExten(“SIP/1001-00000016”, “1”) in new stack
– Timeout on SIP/1001-00000016, continuing…
– Executing [5679@internal:3] GotoIf(“SIP/1001-00000016”, “1?Voicemail_en,1:Voicemail_de,1”) in new stack
– Goto (internal,Voicemail_en,1)
– Executing [Voicemail_en@internal:1] NoOp(“SIP/1001-00000016”, “”) in new stack
– Executing [Voicemail_en@internal:2] Set(“SIP/1001-00000016”, “PIN=1234”) in new stack
– Executing [Voicemail_en@internal:3] Playback(“SIP/1001-00000016”, “vm-password”) in new stack
– <SIP/1001-00000016> Playing ‘vm-password.gsm’ (language ‘en’)
– Executing [Voicemail_en@internal:4] Read(“SIP/1001-00000016”, “DIGIT,4”) in new stack
– Accepting a maximum of 4 digits.
– User entered ‘1234’
– Executing [Voicemail_en@internal:5] Hangup(“SIP/1001-00000016”, “”) in new stack
== Spawn extension (internal, Voicemail_en, 5) exited non-zero on ‘SIP/1001-00000016’

Thanks again!