[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Dado 1.0
- From: Tomas Guisasola Gorham <tomas@...>
- Date: Fri, 2 May 2008 11:52:50 -0300 (BRT)
Hi Mike
Ah. I need, at this point, to work with odbc, as I am currently querying
against mssql and db2/400. I had previously tried to create a higher level
abstraction, similar in some respect to yours, but was running up againt the
same problems, so I backed off and have been using luasql directly. I hadn't
actually tried any of the native drivers, as they wouldn't be useful to me,
at least on any of my current projects.
If you don't need performance, you can redefine Dado's
select to something like:
-- Untested code
-- You'll have to declare next, unpack and table as locals to
-- provide access to them
function select (self, columns, tabname, cond, extra, mode)
local stmt = sql.select (columns, tabname, cond, extra)
local cur = assertexec (self, stmt)
return function ()
-- This table must be created inside this function or it could
-- make `selectall' to return the same row every time.
local t
if mode then t = {} end
--return cur:fetch (t, mode)
local results = { cur:fetch (t, mode) }
if next(results) == nil then -- no more rows
cur:close()
return nil
else
return unpack (results, 1, table.maxn(results))
end
end
end
Regards,
Tomás