Abilio Marques wrote on Sunday, August 23, 2015 4:42 PM > > 3. Lua can return arrays. Also, Lua can return multiple values. Tried > to take advantage of those facts, but while reading the SQLite API > documentation, found no function where I could map multiple values as > the return of a function. Am I wrong? For example: > > select * from table t where fieldA in (lua('return 1,2,3')); > > Could be a useful feat in real scripts with real code.
Something that I've done that's similar-but-different is to use a C preprocessor to preprocess the query, evaluating the Lua prior to the query being prepared in sqlite. In that case (slightly adapted from your example, assuming a lua function named 'csv') select * from table t where fieldA in (lua('return csv(1,2,3)')); resolves to select * from table t where fieldA in (1,2,3); that's still a single return value, but the ability to programmatically manipulate the query prior to execution has been useful to me, particularly being able to write things like select * from lua('most_recent_table()') t where fieldA in (1,2,3); or attach database lua('get_right_dbfile()') as "db1"; assuming that LuaSqlite3 is available, the Lua functions can inspect the database in order to implement their logic. LuaFileSystem can be useful as well. ---------------------------------------------------------------------- This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient, please delete this message.