|
hello Alek
Thanks very much for the reply and taking the time to include a real example. It works great and your explanation is very clear too, they should have got you to write the docs for the lsqlite3 binding :) My original more complex example had lots of columns so I was trying to use the bind_values for that reason, but that doesnt lend itself to my real example where there are also blob columns. I have decided to use the method in your solution, bind() and bind_blob(), its clear to follow just it now streches over a few more source lines, no big deal. The missing finalize and error checking was just due to me snipping the problem down so I could post a concise version in the forum, having said that I had got the prepare line wrongly inside the loop in my original version, thanks for pointing that out. Regards Geoff > Date: Sun, 11 Mar 2012 19:30:36 +0200 > From: alex@declera.com > To: lua-l@lists.lua.org > CC: spammealot1@live.co.uk > Subject: Re: Need some assistance with snippet of Lua/Sqlite code > > On 11.03.2012 13:06, Jeff Smith wrote: > > what I dont like is the fact that I have to add the blob as a NULL using > > the initial bind_values line, which then gets corrected with the next > > bind_blob line. I am sure there is a more correct way of doing this ? > > stmt:bind_values is a simply convenience shortcut, you are free to use > the basic form - stmt:bind (see the attachment) per parameter. > > Also the proper place of db:prepare is outside of the loops. Do not > forget stmt:finalize and error codes checking after every library api > (sql or not) invocation. > > Notes above apply for every sql connector (of course method names may vary). > > Welcome to DB world :-) > Alek |