javascript/WebSQL:如何取消查询。

时间:2022-06-28 19:02:26

I have this situation in which I execute a complex query which will take some time. But sometimes I don't need the result anymore, so I would like to cancel it. Is this possible? Here is the basic structure:

在这种情况下,我执行一个复杂的查询需要一些时间。但有时我不再需要结果,所以我想取消它。这是可能的吗?基本结构如下:

db.transaction(
    function(tx) {
        tx.executeSql('SELECT * FROM ...JOIN ...', [a,b,c], callback) ;
    } 
    , function(err) { .... }
    , function() { /* transaction completed */ }
) ;

1 个解决方案

#1


5  

No abort in WebSQL API. Suggested method invoke invalid SQL to the active transaction that you want to abort and rollback, as follow is:

WebSQL API中没有中止。建议方法调用无效的SQL到您想要中止和回滚的活动事务,如下所示:

var errback = {
  return true; // rollback
}
tx.executeSql('ABORT', [], null, errback); // yes, this will cause error

#1


5  

No abort in WebSQL API. Suggested method invoke invalid SQL to the active transaction that you want to abort and rollback, as follow is:

WebSQL API中没有中止。建议方法调用无效的SQL到您想要中止和回滚的活动事务,如下所示:

var errback = {
  return true; // rollback
}
tx.executeSql('ABORT', [], null, errback); // yes, this will cause error