lua-users home
lua-l archive

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


On Fri, Sep 9, 2016 at 4:49 PM, Leinen, Rick <RLeinen@leviton.com> wrote:

  In the code snippet:

 

local insert_stmt = db:prepare('SELECT * FROM numbers') -- WHERE num1=1')

x = insert_stmt:get_names()

print(x[3])

if sqlite3.ROW == insert_stmt:step() then

    x = insert_stmt:get_values()

end

 

:get_names() works because the first iteration returns the column names.  :step() then iterates to the first row of values so now :get_values works.  Correct?


 No, :get_names() works because db:prepare creates the names (nothing is stepped yet).

Yes, :get_values() works after :step(), which iterates to the first row.

e