lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Jan 20, 2011 at 10:08 AM, Terry Bayne <> wrote:
> 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

Don't use "assert" when you want to handle the error yourself. Take
that out and it might work as you expect. ;)

That will handle *all* errors on the query by closing the connection
and moving on. You may want something more specific.

51st century guy