Hi,
I recently ventured into this area while trying to optimize some code. I have had success using prepared statements with SELECT queries and For row In stmt:rows(sql$). I haven't been able, however to use them with an INSERT or UPDATE action query. I tried stmt:exec() and get an error and stmt:Step() and the error says "expecting a variable". Any help would be appreciated. Thanks.
NathanH
Help with SQLite Prepared Statements
Re: Help with SQLite Prepared Statements
Here is an excerpt from a working script. Maybe it helps.
Code: Select all
stmt=db:prepare([[INSERT INTO billeditems VALUES(NULL, :bill_nr, :date, :name, :brutto, :vat, :amount, :vatvalue)]])
For i,v In Pairs(bill_tetelek)
stmt:bind_names ( { bill_nr = bill_response.szamlaszam,
date = bill_response.date,
name = v.megnevezes,
brutto = v.bruttoertek,
vat = v.afakulcs,
amount = v.mennyiseg,
vatvalue = v.afaertek } )
stmt:dostep()
stmt:reset()
Next
stmt:finalize()
Re: Help with SQLite Prepared Statements
Thanks lazi,
I was using stmt:step() when I should be using stmt:dostep(). That should make all the difference in the world. Thanks very much!!
NathanH
I was using stmt:step() when I should be using stmt:dostep(). That should make all the difference in the world. Thanks very much!!
NathanH