【发布时间】:2018-04-11 18:44:29
【问题描述】:
我们可以使用 Android SQLite rawquery 执行多个语句,例如 SQL Server 存储过程
例子:
string statement1 ="create temp table .....";
string statement2 ="insert into temptable select ..... table1"
string statement3="insert into temptable select..... table2"
string statement4="select ...... from temptable";
Cursor cur=SQLiteDatabase db = this.getReadableDatabase().rawQuery(statement1+" "+statement2+" "+statement3+" "+statement4, null);
还有其他方法可以实现吗?
【问题讨论】:
-
你看到这个答案了吗? stackoverflow.com/questions/32088056/…
-
不,我需要从多个语句计算并准备一个结果集
-
如果你仔细阅读答案你就会明白。使用 db.beginTransaction(); 开始您的批处理查询。然后将所有语句放在 db.setTransactionSuccessful(); 之前。最后是 db.endTransaction();.