[Freeswitch-users] Help in freeswitch dbh query.

Aqs Younas aqsyounas at gmail.com
Tue May 19 18:07:01 MSD 2015


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150519/c4e1e052/attachment.html 


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