我无法在chrome内置数据库中批量插入。 我尝试了以下方法
db.transaction(function(query){
query.executeSql("BEGIN IMMEDIATE TRANSACTION",[],nullDataHandler, errorHandler)
query.executeSql('INSERT INTO cstmr_info (lst_nam ,fst_nam ,doc,email ,mob_no ,hosp )VALUES("a","b","c","d",6256,"dcd")',[],nullDataHandler, errorHandler);
query.executeSql('INSERT INTO cstmr_info (lst_nam ,fst_nam ,doc,email ,mob_no ,hosp )VALUES("a","b","c","d",6256,"dcd")',[],nullDataHandler, errorHandler);
query.executeSql("COMMIT TRANSACTION",[],nullDataHandler, errorHandler);
});
我尝试了这个但是它会抛出错误
db.transaction(function(query){
query.executeSql('INSERT INTO cstmr_info (lst_nam ,fst_nam ,doc,email ,mob_no ,hosp )VALUES("a","b","c","d",6256,"dcd"),("a","b","c","d",6256,"dcd")',[],nullDataHandler, errorHandler);
});
但这也不受支持
答案 0 :(得分:0)
transaction
功能已经完成了交易。
自SQLite 3.7.11以来,支持单个VALUES子句中的多个记录,因此您无法依赖此记录。
在单个事务中使用多个INSERT:
db.transaction(function(tx){
tx.executeSql('INSERT INTO cstmr_info(...) VALUES(...)', ...);
tx.executeSql('INSERT INTO cstmr_info(...) VALUES(...)', ...);
});