Read/Write Error in SQL When Using INSERT OR IGNORE statement

56 views
Skip to first unread message

Nicholas Gibson

unread,
Apr 3, 2017, 4:24:04 PM4/3/17
to Tasker
INSERT statements appear to properly have canRead: true canWrite: true needWrite:true

However, INSERT OR IGNORE statements appear to set canRead: true canWrite: true needWrite:false    as a consequence, if the INSERT attempts to trigger, the following error is generated:

code 3: android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 8)


The exact action that is triggering this is:

SQL Query [ Mode:Raw File:TaskerDB.sqlite Table: Columns: Query:INSERT OR IGNORE INTO tower_locations (cellid, gps) VALUES (%towerid, '%LOC') Selection Paramaters: Order By: Output Column Divider: Variable Array:%temp Use Root:Off] If [ %alstatuses(%index) ~ 2 ]

Pent

unread,
Apr 4, 2017, 2:10:45 AM4/4/17
to Tasker

However, INSERT OR IGNORE statements appear to set canRead: true canWrite: true needWrite:false    as a consequence, if the INSERT attempts to trigger, the following error is generated:

First off: I don't know much about SQL.

Looking around, I'm thinking you mean INSERT IGNORE ? I can't find any reference to 'INSERT OR IGNORE' for mysql.

What I need to know is what I need to match against in order to decide whether the DB needs to be writeable or not.

Pent

Nicholas Gibson

unread,
Apr 4, 2017, 2:14:50 AM4/4/17
to Tasker
SQLite has slightly different syntax than MySQL. I would match against INSERT *. There's actually a few ways to do a conditional insert, but in all of them the engine itself decides if it's going to accept the row, so the DB needs to be accessed with Write.

Or maybe add an option to Force Write Access?

Pent

unread,
Apr 4, 2017, 3:29:41 AM4/4/17
to Tasker
I changed it for next update to match "insert into" with potentially anything in-between
the two words.

Pent

Nicholas Gibson

unread,
Apr 4, 2017, 9:45:54 AM4/4/17
to Tasker
Sweet.  Whats the ETA on this change making it to prod?
Reply all
Reply to author
Forward
0 new messages