Web SQL 将数据插入多行 [英] Web SQL insert data into multiple rows
本文介绍了Web SQL 将数据插入多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾尝试在 Web SQL 数据库中一次将变量插入多行,但使用我所知道的所有方法我都收到错误:
I've tried to insert variables into multiple rows at once in Web SQL database but with all known to me methods I'm getting errors:
("INSERT INTO tab (a,b) VALUES (?,?),(?,?)",[v1,v2,v3,v4])
>> could not prepare statement (1 near ",": syntax error)
("INSERT INTO tab (a,b) VALUES (?,?,?,?)",[v1,v2,v3,v4])
>> could not prepare statement (1 4 values for 2 columns)
("INSERT INTO tab (a,b) VALUES (?,?)",[v1,v2,v3,v4])
>> number of '?' does not match arguments count
哪个对于 Web SQL 是正确的,我的错误在哪里?
Which one is correct for Web SQL and where is my mistake?
推荐答案
由于表选项卡有两列,您只能指定两个值作为一行插入而不是 4.以下查询将起作用:
As table tab has two columns you can specify only two values to be inserted as a row not 4. Following query will work:
("INSERT INTO tab (a,b) VALUES (?,?)",[v1,v2])
您可以在单个事务中多次执行此查询以添加多行以提高整体查询的性能并确保完整性.希望这有帮助!!!
You can execute this query multiple times in a single transaction to add multiple rows to improve performance of overall query and ensure integrity. Hope this helps!!!
这篇关于Web SQL 将数据插入多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文