thank you  steven   for ur reply
now problem has been solved after adding below  line  before function

local row = {}

now it is working fine
thanks


On Tue, Aug 12, 2014 at 7:23 PM, Steven Ayre <steveayre@gmail.com> wrote:
Scope - row only exists inside the function since it's a function argument


On 12 August 2014 08:58, Shabbir abbasi <shabbirabbasi92@gmail.com> wrote:
i am  testing  a script      new_chat.lua    script is below

#!/usr/bin/lua
local dbh = freeswitch.Dbh("odbc://dbname:db_username:db_passwd") -- connect to ODBC database
assert(dbh:connected()) -- exits the script if we didn't connect properly

if dbh:connected() == false then
   freeswitch.consoleLog("ALERT", "lua cannot connect to database" .. dsn .. "\n");
end

sql_query    = "SELECT * FROM cc_card WHERE id ='197'"
dbh:query(sql_query ,function(row)
for key, val in pairs(row) do  
key = val
end
 freeswitch.consoleLog("INFO"," inside  QUERY lastname = " .. row.lastname .. "\n");
freeswitch.consoleLog("INFO"," inside  QUERY  redial = " .. row.redial .. "\n");
end)

freeswitch.consoleLog("INFO"," outside  QUERY  lastname = " .. row.lastname .. "\n");
freeswitch.consoleLog("INFO","  outside  QUERY    redial = " .. row.redial .. "\n");

freeswitch.consoleLog("INFO"," outside  QUERY  lastname = " .. lastname .. "\n");
freeswitch.consoleLog("INFO","  outside  QUERY    redial = " .. redial .. "\n");

dbh:release() -- optional

but here is some problum    in this script  inside query lines are  working  but outside query lines  are not working  WHY  ??  
any suggestions are very wellcome

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@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@freeswitch.org
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org