Hello all,
I have my SQLite db setup in such a way that my ID column is a primary key and it gets generated automatically by the db incrementally after each INSERT. The code looks something like this
String sqlStatement;
DbStatement* pStmt = null;
DbEnumerator* retVal = 0;
Database* db;
result r = E_SUCCESS;
sqlStatement.Append(L"INSERT INTO Track (Description, Title, Distance, Status) VALUES (?,?,?,?)");
db = BootstrapManager::getInstance()->getDatabase();
pStmt = db->CreateStatementN(sqlStatement);
pStmt->BindString(0, *__pDescription);
pStmt->BindString(1, *__pTitle);
pStmt->BindDouble(2, __distance);
pStmt->BindInt(3, __status);
AppLog("Performing transaction with statement: [%d]", statement);
db->BeginTransaction();
retVal = db->ExecuteStatementN(*statement);
db->CommitTransaction();There is one additional column in the Track table called ID but as it is SQLite primary key it gets autogenerated so I don't do manual INSERT on it. Everything works fine but I'm executing this during a construction phase of an object and I need to set a private int __trackerId field on the object after the execution of the transaction but there is no apparent way of getting it from the DbEnumerator that results from the execution. And since I do not know the id I cannot do a SELECT either. Doing a SELECT using the other values is not possible because they are not guaranteed to be unique (even the combination). Any suggestion is appreciated.
Regards Jirka