[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSQL Question
- From: Chris Babcock <cbabcock@...>
- Date: Thu, 20 Jan 2011 20:05:24 -0700
On Thu, Jan 20, 2011 at 10:08 AM, Terry Bayne <trbayne@gmail.com> 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.
Chris
--
51st century guy