[Freeswitch-users] Help in freeswitch dbh query.

Aqs Younas aqsyounas at gmail.com
Tue May 19 18:41:28 MSD 2015


Thanks for reply.

row["inp_"..input]

Solved the problem.

On 19 May 2015 at 07:33, Abaci B <abaci64 at gmail.com> wrote:

> try      * lang = row[inp_..input]*
>
> On Tue, May 19, 2015 at 10:07 AM, Aqs Younas <aqsyounas at gmail.com> wrote:
>
>> Hi, users.
>>
>> I am trying to fetch language from database through freeswitch dbh after
>> user presses some digits on main message.
>>
>> Database table structure is as follow.
>>
>> Id    Did  inp_1  inp_2   inp_3
>>
>> 1     14045872020 <14048002020> english  chinese hindi
>>
>>  *input* = session:playAndGetDigits(1, 1, 3, 3000, "#",main_msg,
>> "/error.wav", "\\d")
>> session:consoleLog("info", "Caller pressed  : ".. input .."\n")
>>
>> sql ="select inp_"..input.." from bible_main where Did = "..Dest
>> session:consoleLog("info", "SQL : ".. sql .."\n")
>>
>> dbh:query(sql, function(row)
>>      * lang = row.inp_..input*
>>       session:consoleLog("info", "Caller has Selected : ".. lang .."\n")
>> end)
>>
>> Running above code gives me below error.
>> 2015-05-17 02:26:20.057184 [ERR] mod_lua.cpp:103
>> /usr/local/freeswitch/scripts/bible.lua:27: attempt to concatenate field
>> 'inp_' (a nil value)
>> stack traceback:
>>         /usr/local/freeswitch/scripts/bible.lua:27: in function
>> </usr/local/freeswitch/scripts/bible.lua:25>
>>         [C]: in function 'query'
>>         /usr/local/freeswitch/scripts/bible.lua:25: in main chunk
>>
>> Actually, i do not know how to concatenate a table value with string so
>> that it reflects the table column. So, i can get value from this.
>>
>> Running it like this, gives perfect result.
>>
>> dbh:query(sql, function(row)
>>      * lang = row.inp_1*
>>       session:consoleLog("info", "Caller has Selected : ".. lang .."\n")
>> end)
>>
>> But I want user's input not some hard coded values for input.
>>
>>
>> Any help in this regard.
>> Thanks.
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150519/d0cdc429/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list