First time using either SQLite or Corona's database functionality...
In MySQL, we can get the next autoincrement value of a table by reading from MySQL's schema table, like this:
SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.WHERE TABLE_SCHEMA='dbName' AND TABLE_NAME='tblName';
SELECT `seq` FROM `sqlite_sequence` WHERE name='tblName';
local foo = db:nrows( [[SELECT `seq` FROM `sqlite_sequence` WHERE name='tblName';]] ) local bah = foo print(bah.seq)
for foobah in db:nrows( [[SELECT `seq` FROM `sqlite_sequence` WHERE name='tblName';]] ) do print(foobah.seq) end
So my conclusion is that perhaps foo is a function rather than a table if the recordset is empty? In which case, is my initial SQL incorrect? Does sqlite_sequence not actually exist as a table? And SQL errors aren't just output to the simulator console?
Or am I still just trying to read the result wrongly?
Further up in the same code file, I have this...
local db = sqlite3.open( system.pathForFile( "local.db", system.DocumentsDirectory ) ) db:exec( [[CREATE TABLE IF NOT EXISTS tblName ( fldID INTEGER PRIMARY KEY autoincrement, fldName, fldName, fldName );]] )