Hi,

This is my first post to the this list, though I do occasionally post on lua-l.

This is a repost of mine to that list, figured it might be more
appropriate here:

--------------
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

Any suggestions would be appreciated.

Thanks
Terry

_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to