Discussion:
[Freeswitch-users] Help in freeswitch dbh query.
Aqs Younas
2015-05-19 14:07:01 UTC
Permalink
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.
Aqs Younas
2015-05-19 14:30:33 UTC
Permalink
Sorry, i resolved the issue. Thanks.
Post by Aqs Younas
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)
/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.
Abaci B
2015-05-19 14:33:56 UTC
Permalink
try * lang = row[inp_..input]*
Post by Aqs Younas
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)
/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.
_________________________________________________________________________
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Aqs Younas
2015-05-19 14:41:28 UTC
Permalink
Thanks for reply.

row["inp_"..input]

Solved the problem.
Post by Abaci B
try * lang = row[inp_..input]*
Post by Aqs Younas
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)
/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.
_________________________________________________________________________
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.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
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Loading...