假设我有 ProductVersion
Table
:
CREATE TABLE ProductVersion
(
Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
PrvVersionName NOT NULL
);
我有这段代码可以在此表上执行INSERT:
SQLiteDatabase database = this.getWritableDatabase();
String sql = "INSERT INTO ProductVersion (PrvVersionName) VALUES (?);";
SQLiteStatement s = database.compileStatement(sql);
s.bindString(1, data.getVersionName());
long id = s.executeInsert();
s.close();
我的问题是,从 s.executeInsert()
返回的值是否与我在执行此 INSERT 后使用 "SELECT last_insert_rowid();"
查询相同?
最佳答案
executeInsert()
将返回插入行的 ID
来自文档
SQLiteStatement.executeInsert ()
Execute this
SQL
statement and return the ID of the row inserted due to this call. TheSQL
statement should be an INSERT for this to be a useful call.
关于android - Statement.executeInsert() 返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50459681/