RANGE: bind or column out of range for INSERT statement
I don't see anything obviously wrong with the info you've posted, but you haven't posted the actual .raw()
statements, which would help with debugging.
So attempting to assist, I would suggest that you add an .on('query-error'
... clause like that below, which will log the SQL that is failing. Many times this will make the problem obvious.
knex.raw(...your-stuff...)
.on('query-error', function(ex, obj) {
console.log("KNEX-query-error ex:", ex, "obj:", obj);
})
Good luck!
The issue stems from SQLite3's lack of support of multi-statements per exec() call, as documented here.
After some testing on my end, I discovered that the SQLite3 engine will assign automatically all the bindings to the first statement of the prepared SQL . Any following statements will be ignored.
This still applies for transactions, as the bindings will be applied to the 'BEGIN TRANSACTION;' statement rather than to the following statements.
The solution is to use a compound INSERT statement with bindings.
Hence this:
INSERT INTO `ds13odba` (FP59STALIB, ID, SURGERY_CODE, TYPE) VALUES (?,?,?,?);
INSERT INTO `ds13odba` (FP59STALIB, ID, SURGERY_CODE, TYPE) VALUES (?,?,?,?);
INSERT INTO `ds13odba` (FP59STALIB, ID, SURGERY_CODE, TYPE) VALUES (?,?,?,?);
becomes this:
INSERT INTO `ds13odba` (FP59STALIB, ID, SURGERY_CODE, TYPE)
VALUES (?,?,?,?), (?,?,?,?), (?,?,?,?);
*Bear in mind that compound INSERT statements are only available as of version 3.7.11 of the SQLite3 engine.
链接地址: http://www.djcxy.com/p/19766.html下一篇: 范围:为INSERT语句绑定或列超出范围