lua-users home
lua-l archive

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


Hi listers,

Using LuaSqlite3, I got the following error in the 'bind' method:

lua: cg.lua:13: bad argument #1 to 'bind' (number expected, got string)

stack traceback:

[C]: in function 'bind'

cg.lua:13: in function 'CathegoryInsert'

cg.lua:18: in main chunk

[C]: ?

The table is:

create table cathegories

(

id integer primary key not null,

entry date not null,

name text not null,

description text

);

And the code not running is:

require('lsqlite3')

function initialize()

db = sqlite3.open('Ting.dbl')

cginsert = db:prepare [[insert into cathegories(entry, name, description) values(date('now'), :name, :description);]]

end

function finalize()

db:close()

end

function CathegoryInsert(name, description)

cginsert:bind(name, description)

cginsert:exec()

end

initialize()

CathegoryInsert('name1', 'description1')

finalize()

'Bind" expect a number as the first argument? Probably is because the first implicit argument to be linked is 'id integer primary key'. But since I don't know what is the next valid integer, I prefer not to mention it in the SQL statement. How to fix this error?

 

Luciano