[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaSQL Question
- From: Terry Bayne <trbayne@...>
- Date: Thu, 20 Jan 2011 11:08:19 -0600
Hi,
I've been using the luaSQL module a lot lately. The documentation for
luaSQL suggests the use of an iterator to 'walk' over the result set:
function rows (connection, sql_statement)
local cursor = assert (connection:execute (sql_statement))
return function ()
return cursor:fetch()
end
end
This works, but often causes an "there are open cursors" error when
closing the connection.
My naive attempt to solve this doesn't appear to work:
function rows(connection, sql_statement)
local cursor = assert (connection:execute (sql_statement))
return function ()
local rc = cursor:fetch()
if (rc == nil) then
cursor:close()
cursor = nil
end
return rc
end
end
Has anyone else solved this issue, if so, any pointers on how I can do so?
Thanks
Terry
--
If you lose your name you become small,
If you lose your spirit you become nothing