Cordova-sqlite-storage: Getting column index out of range while bulk insert

Created on 1 May 2018  路  11Comments  路  Source: storesafe/cordova-sqlite-storage

Hey! I'm trying to implement a bulk insert, I've built this array

[
  [
    "DELETE FROM users",
    [
      "INSERT INTO users (id, name) VALUES (?, ?)",
      [
        9,
        "Contreras 300.000 19-8"
      ]
    ],
    [
      "INSERT INTO users (id, name) VALUES (?, ?)",
      [
        101,
        "Mogoll贸n 300000 23 Nov 16"
      ]
    ],
    [
      "INSERT INTO users (id, name) VALUES (?, ?)",
      [
        103,
        "Rub铆 300000 25-12-16"
      ]
    ]
  ]
]

And I get this error when calling sqlBatch

Error: a statement with no error handler failed: sqlite3_bind_text failure: column index out of range
bug-general question doc-todo testing info needed doc-pitfall

All 11 comments

Please show how you created the table.

This way

let sql = 'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name STRING)';
executeSql(sql, [])

And I'm sending the array above just as it is to the sqlBatch function.
The table is created successfully, I'm just thinking it may be something related to latin ascii codes, due to some names have (accent)

Also which platform(s) did you see this issue on?

Android 7.0

Hi @animista01 you have to remove the outer [ ]. It works fine for me with the outer [ ] removed on Android 5.1.1 & 7.1.1 test devices.

I am marking this as a bug since the error message is not clear enough, hoping to resolve it in an upcoming minor or major release ref: #685, #687, #773.

It's fixed, thanks

Happy to hear!

I did do SELECT COUNT (*) in my test project after the bulk insert and it showed the correct result. I would be happy to post my test project if you like. For further help please raise an issue in litehelpers / Cordova-sqlite-help / issues and I would be happy to take a look. I am also happy to offer private, priority commercial support, please contact in case of interest: sales@litehelpers.net

Am use without [ ],
but error is still,
what i Do,
my create sql here,
sql='DROP TABLE IF EXISTS history';
executeSql(sql);

Object =>InsertId:Undefined
what this error

@CenaSurya it looks like your issue is different and I am really not able to follow what is happening in your code. Please raise a new issue in https://github.com/litehelpers/Cordova-sqlite-help/issues, show the code how you open the database, how you create the table, and how you try to insert the data.

Was this page helpful?
0 / 5 - 0 ratings