Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting column index out of range while bulk insert #780

Open
animista01 opened this issue May 1, 2018 · 11 comments
Open

Getting column index out of range while bulk insert #780

animista01 opened this issue May 1, 2018 · 11 comments

Comments

@animista01
Copy link

animista01 commented May 1, 2018

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
@brody4hire
Copy link

Please show how you created the table.

@animista01
Copy link
Author

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)

@brody4hire
Copy link

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

@animista01
Copy link
Author

Android 7.0

@brody4hire
Copy link

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.

@animista01
Copy link
Author

It's fixed, thanks

@brody4hire
Copy link

Happy to hear!

@brody4hire
Copy link

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: [email protected]

@CenaSurya
Copy link

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

@CenaSurya
Copy link

Object =>InsertId:Undefined
what this error

@brody4hire
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants