SQLITE_RANGE: Bind or Out of Range Column for INSERT Statement

I want to insert rows into a SQLite3 table using a method knex.raw. Unfortunately, I get the error "SQLITE_RANGE", which is why my test fails. I checked the bindings passed to the raw request as follows:

  • They respect the order of the INSERT statement.
  • They respect the specified column types.
  • They respect the number of bindings requested in a raw request.

In addition, I looked online, but could not find a solution to my problem. The following is information about the operation performed:

Error:

SQLITE_RANGE: bind or column index out of range errno: 25, code: 'SQLITE_RANGE'

Table definition:

-- --------------------------------------------------------

--
-- Table structure for table `ds13odba`
--

CREATE TABLE IF NOT EXISTS `ds13odba` (
  `SURGERY_CODE` VARCHAR(6) ,
  `TYPE` VARCHAR(1) ,
  `FP59STALIB` VARCHAR(6) ,
  `ID` INT UNSIGNED NOT NULL ,
  `createdAt` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
  `updatedAt` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL

);

-- --------------------------------------------------------

* , , , , MySQL. SQLite3 SQLite3.

Query:

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 (?,?,?,?);

:

[ 
  '047202', 1, '000001', 'D',
  '047203', 2, '000002', 'D',
  '047204', 3, '000003', 'D' 
]

:

await knex.raw(...convertToInsertSQL(records));

:

await knex.raw(insertStatements.join('\n'), bindings);

?

🦋

0
2

SQLite3 exec(), .

, SQLite3 SQL. .

, "BEGIN TRANSACTION"; .

INSERT .

:

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 (?,?,?,?);

:

INSERT INTO `ds13odba` (FP59STALIB, ID, SURGERY_CODE, TYPE)
  VALUES (?,?,?,?), (?,?,?,?), (?,?,?,?);

* , INSERT 3.7.11 SQLite3.

+1

, , .raw(), .

, , .on('query-error'..., , SQL-, . .

knex.raw(...your-stuff...)
    .on('query-error', function(ex, obj) {
        console.log("KNEX-query-error ex:", ex, "obj:", obj);
    })

!

+1

All Articles